]> git.puffer.fish Git - mirror/frr.git/commitdiff
ripd: null check the key string 2763/head
authorlyq140 <34637052+lyq140@users.noreply.github.com>
Wed, 1 Aug 2018 04:03:24 +0000 (12:03 +0800)
committerlyq140 <34637052+lyq140@users.noreply.github.com>
Wed, 1 Aug 2018 04:03:24 +0000 (12:03 +0800)
This fix a crash of  null pointer.
when we don't add a key string or delete it,
the key is not null but key string is null,
so the code have to return.

Signed-off-by: lyq140 <34637052+lyq140@users.noreply.github.com>
ripd/ripd.c

index 90dc7808ebb802be538ff46dcada1e10a4185cec..fa1188d62517378b529d65bf639b8b71ffaa747d 100644 (file)
@@ -902,7 +902,7 @@ static int rip_auth_md5(struct rip_packet *packet, struct sockaddr_in *from,
                        return 0;
 
                key = key_lookup_for_accept(keychain, md5->keyid);
-               if (key == NULL)
+               if (key == NULL || key->string == NULL)
                        return 0;
 
                strncpy(auth_str, key->string, RIP_AUTH_MD5_SIZE);