lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <9e21220e872dc70dbcd8d4dcba38c3a607052d6e.1652435398.git.aclaudi@redhat.com>
Date:   Fri, 13 May 2022 11:52:30 +0200
From:   Andrea Claudi <aclaudi@...hat.com>
To:     netdev@...r.kernel.org
Cc:     stephen@...workplumber.org, dsahern@...il.com, lucien.xin@...il.com
Subject: [PATCH iproute2] tipc: fix keylen check

Key length check in str2key() is wrong for hex. Fix this using the
proper hex key length.

Fixes: 28ee49e5153b ("tipc: bail out if key is abnormally long")
Suggested-by: Xin Long <lucien.xin@...il.com>
Signed-off-by: Andrea Claudi <aclaudi@...hat.com>
---
 tipc/misc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tipc/misc.c b/tipc/misc.c
index 909975d8..6175bf07 100644
--- a/tipc/misc.c
+++ b/tipc/misc.c
@@ -113,16 +113,15 @@ int str2key(char *str, struct tipc_aead_key *key)
 	    }
 	}
 
-	if (len > TIPC_AEAD_KEYLEN_MAX)
+	key->keylen = ishex ? (len + 1) / 2 : len;
+	if (key->keylen > TIPC_AEAD_KEYLEN_MAX)
 		return -1;
 
 	/* Obtain key: */
 	if (!ishex) {
-		key->keylen = len;
 		memcpy(key->key, str, len);
 	} else {
 		/* Convert hex string to key */
-		key->keylen = (len + 1) / 2;
 		for (i = 0; i < key->keylen; i++) {
 			if (i == 0 && len % 2 != 0) {
 				if (sscanf(str, "%1hhx", &key->key[0]) != 1)
-- 
2.35.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ