]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd lib ospfd pimd ripngd: null chk (PVS-Studio)
authorF. Aragon <paco@voltanet.io>
Tue, 3 Jul 2018 13:39:50 +0000 (15:39 +0200)
committerF. Aragon <paco@voltanet.io>
Tue, 3 Jul 2018 13:39:50 +0000 (15:39 +0200)
Signed-off-by: F. Aragon <paco@voltanet.io>
bgpd/bgp_flowspec_vty.c
bgpd/bgp_route.c
bgpd/bgpd.c
bgpd/rfapi/rfapi.c
bgpd/rfapi/vnc_import_bgp.c
lib/vty.c
lib/workqueue.c
ospfd/ospf_lsa.c
ospfd/ospf_vty.c
pimd/pim_mroute.c
ripngd/ripngd.c

index 90acd8fcb16f48beb0f07ac2436dae0eacd5c4d2..c695e7f12509b22132eca3db7f94e32400ef2a55 100644 (file)
@@ -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 *)
index 7057b62f2b00a47271b8eaa19d28602ae7599392..60d1b5f313dd7bf8f451e1c359c47b76ffc2ea90 100644 (file)
@@ -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));
index 283949ab2a709bf60a3ad5449db3e82e17f73d2c..d21c074ccc2cedd3dbd0943d39acee7e9aa92d5e 100644 (file)
@@ -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;
index 177244d2778bb882b6bd84f1592c2484795fb724..04531433ac2bc86732613e837c4d4d0490ed7c5f 100644 (file)
@@ -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)
index 4bc5535e1bcaf82faec8d4758250be7fef433aec..7182e952b5f49df78af3387fc4133f851d04af93 100644 (file)
@@ -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;
 
index e9d1f2e323747eaf7879af78fb34b1e22513352e..073092dfb6470d762fbb44ec2583787c700bbac0 100644 (file)
--- 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),
index 1af51c06c130ab06c0989a21ce088c8999c0e9a2..39dd142afb9d69f3f837332b2932a0e69d2ad47a 100644 (file)
@@ -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
index 729e50886554438c672652345ce9ef8a824cd2fb..502f23303640f4cd2b370eae68a647d86d5587e9 100644 (file)
@@ -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;
        }
 
index ddf9133ed96ff30ae1dc3c50e6af8990904a18e3..ec654b9e29a13857ed8db0cfc091cda503715d24 100644 (file)
@@ -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) {
index 8462a4fdf8d6a20ea311d007dd9238017677ef59..c7e1a18d280b70731d6b2069a7d1d444e5f219c8 100644 (file)
@@ -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)))) {
index 840157516fb673a81d13ace34a404d999199b9c8..565e151c53eea19b5176ad0869b7b8551b402764 100644 (file)
@@ -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)