bgpd: protect bgp printfrr extension from NULLs

Protect the bgp printfrr extension from NULL input.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
This commit is contained in:
Mark Stapp 2021-03-01 15:40:51 -05:00
parent 0a1e7b612a
commit 001ab42b19

View File

@ -205,8 +205,14 @@ static ssize_t printfrr_bd(char *buf, size_t bsz, const char *fmt,
int prec, const void *ptr)
{
const struct bgp_dest *dest = ptr;
const struct prefix *p = bgp_dest_get_prefix(dest);
const struct prefix *p;
if (dest) {
p = bgp_dest_get_prefix(dest);
prefix2str(p, buf, bsz);
} else {
strlcpy(buf, "NULL", bsz);
}
prefix2str(p, buf, bsz);
return 2;
}