From e65e227f28bf274abf4b46f656c0cb94e7428560 Mon Sep 17 00:00:00 2001 From: lyq140 <34637052+lyq140@users.noreply.github.com> Date: Wed, 1 Aug 2018 12:03:24 +0800 Subject: [PATCH] ripd: null check the key string 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ripd/ripd.c b/ripd/ripd.c index 90dc7808eb..fa1188d625 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -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);