]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Cleanup grabbag of coverity scan issues found 235/head
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 1 Mar 2017 12:47:37 +0000 (07:47 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 1 Mar 2017 13:40:50 +0000 (08:40 -0500)
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_clist.c
bgpd/bgp_encap.c
bgpd/bgp_evpn.c
bgpd/bgp_vty.c
bgpd/bgpd.c
bgpd/rfapi/vnc_zebra.c

index 637c95fa7c40d9251a032fe41773d6f83a68cf07..3def97c73d132eac0cdfb99cc0710f590689a8cc 100644 (file)
@@ -506,18 +506,22 @@ lcommunity_str_get (struct lcommunity *lcom, int i)
 static int
 lcommunity_regexp_include (regex_t * reg, struct lcommunity *lcom, int i)
 {
-  const char *str;
+  char *str;
 
   /* When there is no communities attribute it is treated as empty string. */
   if (lcom == NULL || lcom->size == 0)
-    str = "";
+    str = XSTRDUP (MTYPE_LCOMMUNITY_STR, "");
   else
     str = lcommunity_str_get (lcom, i);
 
   /* Regular expression match.  */
   if (regexec (reg, str, 0, NULL, 0) == 0)
-    return 1;
+    {
+      XFREE (MTYPE_LCOMMUNITY_STR, str);
+      return 1;
+    }
 
+  XFREE (MTYPE_LCOMMUNITY_STR, str);
   /* No match.  */
   return 0;
 }
index 6e021c4e9e44068b78cddf0d06fdc8fee8cac83e..603979942d6bcdfd33f6263b67a60c816e18c3c9 100644 (file)
@@ -589,24 +589,27 @@ DEFUN (show_bgp_ipv4_encap_neighbor_routes,
        "Neighbor to display information about\n"
        "Display routes learned from neighbor\n")
 {
-  int idx_peer = 5;
-  union sockunion su;
+  int idx_peer = 0;
+  union sockunion *su;
   struct peer *peer;
 
-  if (sockunion_str2su (argv[idx_peer]->arg))
+  argv_find(argv, argc, "A.B.C.D", &idx_peer);
+  su = sockunion_str2su (argv[idx_peer]->arg);
+
+  if (!su)
     {
       vty_out (vty, "Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
                return CMD_WARNING;
     }
 
-  peer = peer_lookup (NULL, &su);
+  peer = peer_lookup (NULL, su);
   if (! peer || ! peer->afc[AFI_IP][SAFI_ENCAP])
     {
       vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
       return CMD_WARNING;
     }
 
-  return bgp_show_encap (vty, AFI_IP, NULL, bgp_show_type_neighbor, &su, 0);
+  return bgp_show_encap (vty, AFI_IP, NULL, bgp_show_type_neighbor, su, 0);
 }
 
 DEFUN (show_bgp_ipv6_encap_neighbor_routes,
index b9acbbed08bcef2edf6e2d05d0e8fcf122fcb3a7..1ab8e23236b9ceb256b5ff60da6205d96dca85ec 100644 (file)
@@ -125,7 +125,7 @@ bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr,
                        if (route_length - 4 - 10 - 8 -
                            3 /* label to be read */  >= 32) {
                                p_evpn_p->flags = IP_PREFIX_V6;
-                               memcpy(&(p_evpn_p->ip.v4_addr), pnt, 16);
+                               memcpy(&(p_evpn_p->ip.v6_addr), pnt, 16);
                                pnt += 16;
                                memcpy(&evpn.gw_ip.ipv6, pnt, 16);
                                pnt += 16;
index aa8c3145f98d1b1283de81786afbd42953beeee1..6ad356a04c985a19cdf68fe7011fd25556bb63bb 100644 (file)
@@ -11093,6 +11093,8 @@ DEFUN (no_ip_community_list_standard_all,
 
   int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all);
 
+  XFREE (MTYPE_TMP, str);
+
   if (ret < 0)
     {
       community_list_perror (vty, ret);
@@ -11170,6 +11172,8 @@ DEFUN (no_ip_community_list_expanded_all,
 
   int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all);
 
+  XFREE (MTYPE_TMP, str);
+
   if (ret < 0)
     {
       community_list_perror (vty, ret);
index 3512167b02ff3f24ffd82fc7309c8f07b00a76ba..42a0f8d4b8f871f3caa698522723d12545a6d346 100644 (file)
@@ -2524,7 +2524,7 @@ peer_group_delete (struct peer_group *group)
       list_delete (group->listen_range[afi]);
     }
 
-  XFREE(MTYPE_BGP_PEER_HOST, group->name);
+  XFREE(MTYPE_PEER_GROUP_HOST, group->name);
   group->name = NULL;
 
   group->conf->group = NULL;
@@ -5458,7 +5458,7 @@ peer_prefix_list_unset (struct peer *peer, afi_t afi, safi_t safi, int direct)
       if (gfilter->plist[direct].name)
        {
          if (filter->plist[direct].name)
-           XSTRDUP(MTYPE_BGP_FILTER_NAME, filter->plist[direct].name);
+           XFREE(MTYPE_BGP_FILTER_NAME, filter->plist[direct].name);
          filter->plist[direct].name = XSTRDUP(MTYPE_BGP_FILTER_NAME, gfilter->plist[direct].name);
          filter->plist[direct].plist = gfilter->plist[direct].plist;
           peer_on_policy_change(peer, afi, safi,
index 23b6e9dbb48856d1017f8ea640362e3fc897965b..84b299ce1d120d9e224d2d8c0730a24f69154d18 100644 (file)
@@ -547,6 +547,7 @@ vnc_zebra_route_msg (
       api.nexthop = nhp_ary;
       api.ifindex_num = 0;
       api.instance = 0;
+      api.safi = SAFI_UNICAST;
 
       if (BGP_DEBUG (zebra, ZEBRA))
         {
@@ -582,6 +583,7 @@ vnc_zebra_route_msg (
       api.ifindex_num = 1;
       api.ifindex = &ifindex;
       api.instance = 0;
+      api.safi = SAFI_UNICAST;
 
       if (BGP_DEBUG (zebra, ZEBRA))
         {