Browse Source

bgpd: Fix crash in 'show ip bgp nexthop'

* bgp_nexthop.c: (show_ip_bgp_nexthop_table) the AFIs are sparse, and start
  from 1, check there's a table before derefing so as not to crash.
Paul Jakma 3 years ago
parent
commit
789dfc9fe0
1 changed files with 3 additions and 0 deletions
  1. 3 0
      bgpd/bgp_nexthop.c

+ 3 - 0
bgpd/bgp_nexthop.c

@@ -421,6 +421,9 @@ show_ip_bgp_nexthop_table (struct vty *vty, int detail)
   vty_out (vty, "Current BGP nexthop cache:%s", VTY_NEWLINE);
   for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
     {
+      if (!bgp_nexthop_cache_table[afi])
+        continue;
+      
       for (rn = bgp_table_top (bgp_nexthop_cache_table[afi]); rn; rn = bgp_route_next (rn))
 	{
 	  if ((bnc = rn->info) != NULL)