diff options
| author | Mark Stapp <mjs@voltanet.io> | 2021-03-01 15:40:51 -0500 |
|---|---|---|
| committer | Mark Stapp <mjs@voltanet.io> | 2021-03-01 15:40:51 -0500 |
| commit | 001ab42b1916e7ad69b77a7defdfd5e728104688 (patch) | |
| tree | df59336d1676ead9d1951e6a2432e42b52558943 | |
| parent | 0a1e7b612af18fc2ad476d00e6ad428acf17fb4f (diff) | |
bgpd: protect bgp printfrr extension from NULLs
Protect the bgp printfrr extension from NULL input.
Signed-off-by: Mark Stapp <mjs@voltanet.io>
| -rw-r--r-- | bgpd/bgp_table.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/bgpd/bgp_table.c b/bgpd/bgp_table.c index 022a6413e2..7e3aa2a48a 100644 --- a/bgpd/bgp_table.c +++ b/bgpd/bgp_table.c @@ -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; } |
