From 73c0a1bb3a8e1a6d3ce9a9319547e55675cf1813 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Thu, 16 Apr 2020 16:13:01 +0300 Subject: [PATCH] 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 --- bgpd/bgp_route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.39.5