From 5f71d11c122064eef47d3d040a70a20be00bcb52 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 31 Jan 2020 10:26:33 -0500 Subject: [PATCH 1/4] bgpd: Tell Coverity SA that regex cannot be NULL here The coverity SA believes that the regex value can possibly be NULL. Not possible so let's make it happy. Signed-off-by: Donald Sharp --- bgpd/bgp_route.c | 1 + 1 file changed, 1 insertion(+) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 78f03a707d..d3a5774570 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -10708,6 +10708,7 @@ DEFUN (show_ip_bgp_regexp, if (argv_find(argv, argc, "REGEX", &idx)) regstr = argv[idx]->arg; + assert(regstr); return bgp_show_regexp(vty, bgp, (const char *)regstr, afi, safi, bgp_show_type_regexp, uj); } From 698ba8d02688ef7b9532c9a6dc441f841b9357ee Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 31 Jan 2020 10:30:22 -0500 Subject: [PATCH 2/4] bgpd: Remove dead call to get_afi_safi_str There is no need for a call into get_afi_safi_str for the json side since we add it based upon the afi safi str below. Signed-off-by: Donald Sharp --- bgpd/bgp_vty.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 1cd2f0a397..645c502020 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9593,8 +9593,7 @@ static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( get_afi_safi_str(afi, safi, false)); vty_out(vty, " F bit : "); - } else - get_afi_safi_str(afi, safi, true); + } if (peer->nsf[afi][safi] && CHECK_FLAG(peer->af_cap[afi][safi], From 19d95d40c08d96b8b6ba6c7d224701db339893ab Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 31 Jan 2020 10:44:23 -0500 Subject: [PATCH 3/4] lib: Test return of fcntl in agentx.c The agentx.c code was calling fcntl but not testing return code and handling it, thus making SA unhappy. Fix. Signed-off-by: Donald Sharp --- lib/agentx.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/agentx.c b/lib/agentx.c index 2c6a43d1a7..b479b5ea4c 100644 --- a/lib/agentx.c +++ b/lib/agentx.c @@ -55,28 +55,42 @@ static int agentx_timeout(struct thread *t) static int agentx_read(struct thread *t) { fd_set fds; - int flags; + int flags, new_flags = 0; int nonblock = false; struct listnode *ln = THREAD_ARG(t); list_delete_node(events, ln); /* fix for non blocking socket */ flags = fcntl(THREAD_FD(t), F_GETFL, 0); - if (-1 == flags) + if (-1 == flags) { + flog_err(EC_LIB_SYSTEM_CALL, "Failed to get FD settings fcntl: %s(%d)", + strerror(errno), errno); return -1; + } if (flags & O_NONBLOCK) nonblock = true; else - fcntl(THREAD_FD(t), F_SETFL, flags | O_NONBLOCK); + new_flags = fcntl(THREAD_FD(t), F_SETFL, flags | O_NONBLOCK); + + if (new_flags == -1) + flog_err(EC_LIB_SYSTEM_CALL, "Failed to set snmp fd non blocking: %s(%d)", + strerror(errno), errno); FD_ZERO(&fds); FD_SET(THREAD_FD(t), &fds); snmp_read(&fds); /* Reset the flag */ - if (!nonblock) - fcntl(THREAD_FD(t), F_SETFL, flags); + if (!nonblock) { + new_flags = fcntl(THREAD_FD(t), F_SETFL, flags); + + if (new_flags == -1) + flog_err( + EC_LIB_SYSTEM_CALL, + "Failed to set snmp fd back to original settings: %s(%d)", + strerror(errno), errno); + } netsnmp_check_outstanding_agent_requests(); agentx_events_update(); From 9275682559af65ac711a36e9caa3b1d87631d5ab Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 31 Jan 2020 10:46:05 -0500 Subject: [PATCH 4/4] zebra: top has already been derefed The top variable has already been derefed by the time we get to the test to see if it is non-NULL. No need to check it. Signed-off-by: Donald Sharp --- zebra/zebra_nhg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 732349a570..fb8cfa5c9f 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -1486,7 +1486,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re, * resolved by a route NH1. The exception is if the route is a * host route. */ - if (top && rn == top) + if (rn == top) if (((afi == AFI_IP) && (rn->p.prefixlen != 32)) || ((afi == AFI_IP6) && (rn->p.prefixlen != 128))) { if (IS_ZEBRA_DEBUG_RIB_DETAILED)