]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tipc: bail out if key is abnormally long
authorAndrea Claudi <aclaudi@redhat.com>
Sat, 1 May 2021 16:32:30 +0000 (18:32 +0200)
committerDavid Ahern <dsahern@kernel.org>
Sun, 9 May 2021 22:08:47 +0000 (22:08 +0000)
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 <aclaudi@redhat.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
tipc/misc.c

index 1daf3072a8788a83e553dc2426a04b5e7cea0f9b..909975d8b7fe7e5f976a17fc4b3cab1a18232ae6 100644 (file)
@@ -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;