]> git.puffer.fish Git - mirror/frr.git/commitdiff
ripd: null check key 2766/head
authorlyq140 <34637052+lyq140@users.noreply.github.com>
Wed, 1 Aug 2018 12:48:36 +0000 (20:48 +0800)
committerlyq140 <34637052+lyq140@users.noreply.github.com>
Wed, 1 Aug 2018 12:48:36 +0000 (20:48 +0800)
Fix ripd crash of null pointer.
when authenticate a rip packet,
the key pointer or the key string pointer may be null,
the code have to return then.

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

index c3e1a6d3c4fa409f58e2f632ba215782101d8ce2..494f6f643088f988f9ff8630d02adcdb2a7d6520 100644 (file)
@@ -172,7 +172,7 @@ struct key *key_match_for_accept(const struct keychain *keychain,
                if (key->accept.start == 0
                    || (key->accept.start <= now
                        && (key->accept.end >= now || key->accept.end == -1)))
-                       if (strncmp(key->string, auth_str, 16) == 0)
+                       if (key->string && (strncmp(key->string, auth_str, 16) == 0))
                                return key;
        }
        return NULL;
index fa1188d62517378b529d65bf639b8b71ffaa747d..f7d6d3d9297d64710ee59e2a5d0f798a8db5c81f 100644 (file)
@@ -828,7 +828,7 @@ static int rip_auth_simple_password(struct rte *rte, struct sockaddr_in *from,
                struct key *key;
 
                keychain = keychain_lookup(ri->key_chain);
-               if (keychain == NULL)
+               if (keychain == NULL || keychain->key == NULL)
                        return 0;
 
                key = key_match_for_accept(keychain, auth_str);