diff options
author | Mark Stapp <mjs@voltanet.io> | 2021-03-01 14:51:13 +0100 |
---|---|---|
committer | Mark Stapp <mjs@voltanet.io> | 2021-03-01 14:51:13 +0100 |
commit | e0b5ca875b0b48ef8785633c850be21a92a9b2a5 (patch) | |
tree | 2d0ec301183beee7ccb18dce60530a258072f498 /lib/nexthop.c | |
parent | Merge pull request #8073 from idryzhov/vtysh-show-config (diff) | |
download | frr-e0b5ca875b0b48ef8785633c850be21a92a9b2a5.tar.xz frr-e0b5ca875b0b48ef8785633c850be21a92a9b2a5.zip |
lib: print NULL for NULL nexthops
Instead of crashing, print "NULL" when printfrr callback for
nexthops is called for a NULL nexthop argument.
Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'lib/nexthop.c')
-rw-r--r-- | lib/nexthop.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/nexthop.c b/lib/nexthop.c index b2fa94569..dd8c10820 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -739,6 +739,16 @@ static ssize_t printfrr_nh(char *buf, size_t bsz, const char *fmt, const char *s, *v_is = "", *v_via = "", *v_viaif = "via "; ssize_t ret = 3; + /* NULL-check */ + if (nexthop == NULL) { + if (fmt[2] == 'v' && fmt[3] == 'v') + ret++; + + strlcpy(buf, "NULL", bsz); + + return ret; + } + switch (fmt[2]) { case 'v': if (fmt[3] == 'v') { |