From: Andrea Claudi Date: Sat, 1 May 2021 16:32:30 +0000 (+0200) Subject: tipc: bail out if key is abnormally long X-Git-Tag: v5.14.0~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28ee49e5153b02698f100ad4e390fe700f7bcf32;p=thirdparty%2Fiproute2.git tipc: bail out if key is abnormally long tipc segfaults when called with an abnormally long key: $ tipc node set key 0123456789abcdef0123456789abcdef0123456789abcdef *** buffer overflow detected ***: terminated Fix this returning an error if key length is longer than TIPC_AEAD_KEYLEN_MAX. Fixes: 24bee3bf9752 ("tipc: add new commands to set TIPC AEAD key") Signed-off-by: Andrea Claudi Signed-off-by: David Ahern --- diff --git a/tipc/misc.c b/tipc/misc.c index 1daf3072a..909975d8b 100644 --- a/tipc/misc.c +++ b/tipc/misc.c @@ -113,6 +113,9 @@ int str2key(char *str, struct tipc_aead_key *key) } } + if (len > TIPC_AEAD_KEYLEN_MAX) + return -1; + /* Obtain key: */ if (!ishex) { key->keylen = len;