diff options
| author | Mark Stapp <mjs@voltanet.io> | 2021-03-01 08:51:13 -0500 | 
|---|---|---|
| committer | Mark Stapp <mjs@voltanet.io> | 2021-03-01 08:51:13 -0500 | 
| commit | e0b5ca875b0b48ef8785633c850be21a92a9b2a5 (patch) | |
| tree | 2d0ec301183beee7ccb18dce60530a258072f498 /lib/nexthop.c | |
| parent | 0a1e7b612af18fc2ad476d00e6ad428acf17fb4f (diff) | |
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 b2fa945690..dd8c108205 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') {  | 
