]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: protect bgp printfrr extension from NULLs
authorMark Stapp <mjs@voltanet.io>
Mon, 1 Mar 2021 20:40:51 +0000 (15:40 -0500)
committerMark Stapp <mjs@voltanet.io>
Mon, 1 Mar 2021 20:40:51 +0000 (15:40 -0500)
Protect the bgp printfrr extension from NULL input.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
bgpd/bgp_table.c

index 022a6413e2bb2cf2ac5a32a751f10e976a4b161e..7e3aa2a48a50bc4c9fa3861f5e517a32868370e3 100644 (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;
 }