From: Donatas Abraitis Date: Thu, 16 Apr 2020 13:13:01 +0000 (+0300) Subject: bgpd: Add a sanitify check for bgp_nexthop_cache against NULL X-Git-Tag: frr-7.3.1~7^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=73c0a1bb3a8e1a6d3ce9a9319547e55675cf1813;p=mirror%2Ffrr.git bgpd: Add a sanitify check for bgp_nexthop_cache against NULL In real world sometimes happens that bgp_nexthop_cache is NULL. Avoid segfaulting when using `show [ip] bgp ...` CLI commands. Signed-off-by: Donatas Abraitis --- diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 7aad1e4ecd..69d12aaaea 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -7159,7 +7159,7 @@ static char *bgp_nexthop_hostname(struct peer *peer, struct bgp_nexthop_cache *bnc) { if (peer->hostname - && CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHOW_HOSTNAME) + && CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHOW_HOSTNAME) && bnc && CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED)) return peer->hostname; return NULL;