From d880a643d75e1f6a2845a49843c703fc4e5a0610 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 27 Jul 2022 09:36:17 -0400 Subject: [PATCH] bgpd: Ensure we are not using AFI_MAX When using bgp_vty_afi_from_str it can return AFI_MAX( but in practice never will with our cli ). In bgp_default_afi_safi_cmd the code directly references: bgp->default_afi[afi][safi] = TRUE; and if afi is AFI_MAX FRRR would be accessing memory where it should not be. Let's just provide some assurances for coverity that this never happens. Signed-off-by: Donald Sharp --- bgpd/bgp_vty.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index bb0be50048..b8e426a52b 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -3855,6 +3855,11 @@ DEFPY(bgp_default_afi_safi, bgp_default_afi_safi_cmd, afi_t afi = bgp_vty_afi_from_str(afi_str); safi_t safi; + /* + * Impossible situation but making coverity happy + */ + assert(afi != AFI_MAX); + if (strmatch(safi_str, "labeled")) safi = bgp_vty_safi_from_str("labeled-unicast"); else