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>
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;
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);