From: F. Aragon Date: Tue, 3 Jul 2018 13:39:50 +0000 (+0200) Subject: bgpd lib ospfd pimd ripngd: null chk (PVS-Studio) X-Git-Tag: frr-6.1-dev~196^2 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=b575a12c878f5fc0c346204215f648e112f026e0;p=mirror_frr.git bgpd lib ospfd pimd ripngd: null chk (PVS-Studio) Signed-off-by: F. Aragon --- diff --git a/bgpd/bgp_flowspec_vty.c b/bgpd/bgp_flowspec_vty.c index 90acd8fcb..c695e7f12 100644 --- a/bgpd/bgp_flowspec_vty.c +++ b/bgpd/bgp_flowspec_vty.c @@ -274,7 +274,7 @@ void route_vty_out_flowspec(struct vty *vty, struct prefix *p, else json_nlri_path = json_paths; } - if (display == NLRI_STRING_FORMAT_LARGE) + if (display == NLRI_STRING_FORMAT_LARGE && binfo) vty_out(vty, "BGP flowspec entry: (flags 0x%x)\n", binfo->flags); bgp_fs_nlri_get_string((unsigned char *) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 7057b62f2..60d1b5f31 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -2168,7 +2168,6 @@ struct bgp_process_queue { static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) { - struct prefix *p = &rn->p; struct bgp_info *new_select; struct bgp_info *old_select; struct bgp_info_pair old_and_new; @@ -2191,6 +2190,8 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn, return; } + struct prefix *p = &rn->p; + debug = bgp_debug_bestpath(&rn->p); if (debug) { prefix2str(&rn->p, pfx_buf, sizeof(pfx_buf)); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 283949ab2..d21c074cc 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -1026,9 +1026,11 @@ static inline bgp_peer_sort_t peer_calc_sort(struct peer *peer) else if (peer->as_type == AS_EXTERNAL) return BGP_PEER_EBGP; - else if (peer->as_type == AS_SPECIFIED && peer->as) + else if (peer->as_type == AS_SPECIFIED && peer->as) { + assert(bgp); return (bgp->as == peer->as ? BGP_PEER_IBGP : BGP_PEER_EBGP); + } else { struct peer *peer1; diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index 177244d27..04531433a 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -2336,7 +2336,7 @@ int rfapi_reopen(struct rfapi_descriptor *rfd, struct bgp *bgp) h = bgp->rfapi; - assert(!CHECK_FLAG(h->flags, RFAPI_INCALLBACK)); + assert(h != NULL && !CHECK_FLAG(h->flags, RFAPI_INCALLBACK)); if (CHECK_FLAG(rfd->flags, RFAPI_HD_FLAG_CLOSING_ADMINISTRATIVELY) diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c index 4bc5535e1..7182e952b 100644 --- a/bgpd/rfapi/vnc_import_bgp.c +++ b/bgpd/rfapi/vnc_import_bgp.c @@ -2904,6 +2904,8 @@ void vnc_import_bgp_redist_disable(struct bgp *bgp, afi_t afi) struct rfapi_descriptor *rfd; vncHDBgpDirect.peer = bi->peer; + assert(bi->extra); + rfd = bi->extra->vnc.export .rfapi_handle; diff --git a/lib/vty.c b/lib/vty.c index e9d1f2e32..073092dfb 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -479,6 +479,8 @@ static int vty_command(struct vty *vty, char *buf) const char *protocolname; char *cp = NULL; + assert(vty); + /* * Log non empty command lines */ @@ -496,13 +498,13 @@ static int vty_command(struct vty *vty, char *buf) /* format the base vty info */ snprintf(vty_str, sizeof(vty_str), "vty[??]@%s", vty->address); - if (vty) - for (i = 0; i < vector_active(vtyvec); i++) - if (vty == vector_slot(vtyvec, i)) { - snprintf(vty_str, sizeof(vty_str), - "vty[%d]@%s", i, vty->address); - break; - } + + for (i = 0; i < vector_active(vtyvec); i++) + if (vty == vector_slot(vtyvec, i)) { + snprintf(vty_str, sizeof(vty_str), "vty[%d]@%s", + i, vty->address); + break; + } /* format the prompt */ snprintf(prompt_str, sizeof(prompt_str), cmd_prompt(vty->node), diff --git a/lib/workqueue.c b/lib/workqueue.c index 1af51c06c..39dd142af 100644 --- a/lib/workqueue.c +++ b/lib/workqueue.c @@ -245,10 +245,11 @@ int work_queue_run(struct thread *thread) char yielded = 0; wq = THREAD_ARG(thread); - wq->thread = NULL; assert(wq); + wq->thread = NULL; + /* calculate cycle granularity: * list iteration == 1 run * listnode processing == 1 cycle diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 729e50886..502f23303 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -1889,7 +1889,7 @@ struct ospf_lsa *ospf_translated_nssa_refresh(struct ospf *ospf, zlog_debug( "ospf_translated_nssa_refresh(): no Type-7 found for " "Type-5 LSA Id %s", - inet_ntoa(type5->data->id)); + type5 ? inet_ntoa(type5->data->id) : "(null)"); return NULL; } @@ -1899,7 +1899,7 @@ struct ospf_lsa *ospf_translated_nssa_refresh(struct ospf *ospf, zlog_debug( "ospf_translated_nssa_refresh(): No translated Type-5 " "found for Type-7 with Id %s", - inet_ntoa(type7->data->id)); + type7 ? inet_ntoa(type7->data->id) : "(null)"); return NULL; } @@ -1912,7 +1912,7 @@ struct ospf_lsa *ospf_translated_nssa_refresh(struct ospf *ospf, zlog_debug( "ospf_translated_nssa_refresh(): Could not translate " "Type-7 for %s to Type-5", - inet_ntoa(type7->data->id)); + type7 ? inet_ntoa(type7->data->id) : "(null)"); return NULL; } @@ -1921,7 +1921,7 @@ struct ospf_lsa *ospf_translated_nssa_refresh(struct ospf *ospf, zlog_debug( "ospf_translated_nssa_refresh(): Could not install " "translated LSA, Id %s", - inet_ntoa(type7->data->id)); + type7 ? inet_ntoa(type7->data->id) : "(null)"); return NULL; } diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index ddf9133ed..ec654b9e2 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -4809,16 +4809,19 @@ static void show_ip_ospf_nbr_nbma_detail_sub(struct vty *vty, vty_out(vty, " Poll interval %d\n", nbr_nbma->v_poll); /* Show poll-interval timer. */ - if (use_json) { - long time_store; - time_store = monotime_until(&nbr_nbma->t_poll->u.sands, NULL) - / 1000LL; - json_object_int_add(json_sub, "pollIntervalTimerDueMsec", - time_store); - } else - vty_out(vty, " Poll timer due in %s\n", - ospf_timer_dump(nbr_nbma->t_poll, timebuf, - sizeof(timebuf))); + if (nbr_nbma->t_poll) { + if (use_json) { + long time_store; + time_store = monotime_until(&nbr_nbma->t_poll->u.sands, + NULL) / 1000LL; + json_object_int_add(json_sub, + "pollIntervalTimerDueMsec", + time_store); + } else + vty_out(vty, " Poll timer due in %s\n", + ospf_timer_dump(nbr_nbma->t_poll, timebuf, + sizeof(timebuf))); + } /* Show poll-interval timer thread. */ if (use_json) { diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c index 8462a4fdf..c7e1a18d2 100644 --- a/pimd/pim_mroute.c +++ b/pimd/pim_mroute.c @@ -152,7 +152,7 @@ static int pim_mroute_msg_nocache(int fd, struct interface *ifp, struct pim_rpf *rpg; struct prefix_sg sg; - rpg = RP(pim_ifp->pim, msg->im_dst); + rpg = pim_ifp ? RP(pim_ifp->pim, msg->im_dst) : NULL; /* * If the incoming interface is unknown OR * the Interface type is SSM we don't need to @@ -278,7 +278,7 @@ static int pim_mroute_msg_wholepkt(int fd, struct interface *ifp, pim_ifp = up->rpf.source_nexthop.interface->info; - rpg = RP(pim_ifp->pim, sg.grp); + rpg = pim_ifp ? RP(pim_ifp->pim, sg.grp) : NULL; if ((pim_rpf_addr_is_inaddr_none(rpg)) || (!pim_ifp) || (!(PIM_I_am_DR(pim_ifp)))) { diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index 840157516..565e151c5 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -1516,9 +1516,10 @@ int ripng_write_rte(int num, struct stream *s, struct prefix_ipv6 *p, } /* Write routing table entry. */ - if (!nexthop) + if (!nexthop) { + assert(p); stream_write(s, (uint8_t *)&p->prefix, sizeof(struct in6_addr)); - else + } else stream_write(s, (uint8_t *)nexthop, sizeof(struct in6_addr)); stream_putw(s, tag); if (p)