]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd, lib: fix a few scan-build catches
authorQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 20 Dec 2016 03:12:32 +0000 (03:12 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 20 Dec 2016 03:26:47 +0000 (03:26 +0000)
Fixes a couple null pointer derefs and uninit'd values.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
bgpd/bgp_route.c
lib/command.c
lib/command_match.c
lib/routemap.c

index cfc4ec34077f8a4b3c6de5ef1f5ab7b10b21317d..67ea4db2d19dacbdf1606b783ee58e60b1fbe647 100644 (file)
@@ -9497,7 +9497,7 @@ DEFUN (show_ip_bgp_instance_neighbor_advertised_route,
   char *vrf = NULL;
   char *rmap_name = NULL;
   char *peerstr = NULL;
-  int rcvd;
+  int rcvd = 0;
 
   struct peer *peer;
 
index ca0d0c001bad6009b96f08b5b9934cb7f6082cce..3cce4584e97c22f244cd21fb1f8c83b62b2f72a1 100644 (file)
@@ -304,6 +304,9 @@ cmd_concat_strvec (vector v)
     if (vector_slot (v, i))
       strsize += strlen ((char *) vector_slot (v, i)) + 1;
 
+  if (strsize == 0)
+    return XSTRDUP (MTYPE_TMP, "");
+
   char *concatenated = calloc (sizeof (char), strsize);
   for (unsigned int i = 0; i < vector_active (v); i++)
   {
index 62905a4f7f8755fbb95b331cf160eee8adebfc34..d228563240075eab177b5ed886e28de5e0c88f8f 100644 (file)
@@ -482,7 +482,7 @@ add_nexthops (struct list *list, struct graph_node *node,
       child = vector_slot (node->to, i);
       size_t j;
       struct cmd_token *token = child->data;
-      if (!token->allowrepeat)
+      if (!token->allowrepeat && stack)
         {
           for (j = 0; j < stackpos; j++)
             if (child == stack[j])
index 5f2b2c0dfbb21775e2b35868744839ad6ef5f13d..ce8494254533eb62263225895781a78ff405ef45 100644 (file)
@@ -989,9 +989,11 @@ vty_show_route_map_entry (struct vty *vty, struct route_map *map)
 
   /* Print the name of the protocol */
   if (zlog_default)
+  {
     vty_out (vty, "%s", zlog_proto_names[zlog_default->protocol]);
-  if (zlog_default->instance)
-    vty_out (vty, " %d", zlog_default->instance);
+    if (zlog_default->instance)
+      vty_out (vty, " %d", zlog_default->instance);
+  }
   vty_out (vty, ":%s", VTY_NEWLINE);
 
   for (index = map->head; index; index = index->next)
@@ -2766,17 +2768,16 @@ DEFUN (rmap_call,
   struct route_map_index *index = VTY_GET_CONTEXT (route_map_index);
   const char *rmap = argv[idx_word]->arg;
 
-  if (index)
+  assert(index);
+
+  if (index->nextrm)
     {
-      if (index->nextrm)
-       {
-         route_map_upd8_dependency (RMAP_EVENT_CALL_DELETED,
-                                    index->nextrm,
-                                    index->map->name);
-         XFREE (MTYPE_ROUTE_MAP_NAME, index->nextrm);
-       }
-      index->nextrm = XSTRDUP (MTYPE_ROUTE_MAP_NAME, rmap);
+      route_map_upd8_dependency (RMAP_EVENT_CALL_DELETED,
+                                 index->nextrm,
+                                 index->map->name);
+      XFREE (MTYPE_ROUTE_MAP_NAME, index->nextrm);
     }
+  index->nextrm = XSTRDUP (MTYPE_ROUTE_MAP_NAME, rmap);
 
   /* Execute event hook. */
   route_map_upd8_dependency (RMAP_EVENT_CALL_ADDED,