]> git.proxmox.com Git - mirror_frr.git/commitdiff
pimd: Fix various sizeof and buffer length issues
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 6 Apr 2017 21:57:24 +0000 (17:57 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 6 Apr 2017 21:57:24 +0000 (17:57 -0400)
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_cmd.c
pimd/pim_tlv.c
pimd/pim_zlookup.c

index 627971d3f9779e7fc8fb70687683010e96f2ce87..0478dc1b4815ef14f01b0e46e549519a75beb200 100644 (file)
@@ -830,7 +830,9 @@ static void pim_show_interfaces_single(struct vty *vty, const char *ifname, u_ch
         sec_list = json_object_new_array();
         for (ALL_LIST_ELEMENTS_RO(pim_ifp->sec_addr_list, sec_node, sec_addr)) {
           json_object_array_add(sec_list,
-                                json_object_new_string(prefix2str(&sec_addr->addr, pbuf, PREFIX2STR_BUFFER)));
+                                json_object_new_string(prefix2str(&sec_addr->addr,
+                                                                 pbuf,
+                                                                 sizeof(pbuf))));
         }
         json_object_object_add(json_row, "secondaryAddressList", sec_list);
       }
@@ -926,7 +928,9 @@ static void pim_show_interfaces_single(struct vty *vty, const char *ifname, u_ch
                 inet_ntoa(ifaddr), VTY_NEWLINE);
         for (ALL_LIST_ELEMENTS_RO(pim_ifp->sec_addr_list, sec_node, sec_addr)) {
           vty_out(vty, "             %s%s",
-                  prefix2str(&sec_addr->addr, pbuf, PREFIX2STR_BUFFER), VTY_NEWLINE);
+                  prefix2str(&sec_addr->addr,
+                            pbuf,
+                            sizeof(pbuf)), VTY_NEWLINE);
         }
       } else {
         vty_out(vty, "Address    : %s%s", inet_ntoa(ifaddr), VTY_NEWLINE);
@@ -1611,9 +1615,9 @@ static void pim_show_neighbors_secondary(struct vty *vty)
                     neigh_src_str, sizeof(neigh_src_str));
 
       for (ALL_LIST_ELEMENTS_RO(neigh->prefix_list, prefix_node, p)) {
-       char neigh_sec_str[100];
+       char neigh_sec_str[PREFIX2STR_BUFFER];
 
-       prefix2str(p, neigh_sec_str, 100);
+       prefix2str(p, neigh_sec_str, sizeof(neigh_sec_str));
 
        vty_out(vty, "%-9s %-15s %-15s %-15s%s",
                ifp->name,
index 1d58ce3ac63f7f5bd3e54cd5478b51c15d937091..259ed44c714de11767994c9d148b912822eca4b0 100644 (file)
@@ -523,7 +523,7 @@ pim_parse_addr_ucast (struct prefix *p,
 
     p->family = AF_INET6;
     p->prefixlen = IPV6_MAX_PREFIXLEN;
-    memcpy(&p->u.prefix6, addr, 16);
+    memcpy(&p->u.prefix6, addr, sizeof(struct in6_addr));
     addr += sizeof(struct in6_addr);
 
     break;
index 620137b33b573c25bc6c0d9beda064b502d6919f..27bd1370438a5593ca67cb36d67f1cea2fd93749 100644 (file)
@@ -252,12 +252,16 @@ static int zclient_read_nexthop(struct zclient *zlookup,
       break;
     case NEXTHOP_TYPE_IPV6_IFINDEX:
       nexthop_tab[num_ifindex].nexthop_addr.family = AF_INET6;
-      stream_get (&nexthop_tab[num_ifindex].nexthop_addr.u.prefix6, s, 16);
+      stream_get (&nexthop_tab[num_ifindex].nexthop_addr.u.prefix6,
+                 s,
+                 sizeof(struct in6_addr));
       nexthop_tab[num_ifindex].ifindex = stream_getl (s);
 
       p.family = AF_INET6;
       p.prefixlen = IPV6_MAX_PREFIXLEN;
-      memcpy (&p.u.prefix6, &nexthop_tab[num_ifindex].nexthop_addr.u.prefix6, 16);
+      memcpy (&p.u.prefix6,
+             &nexthop_tab[num_ifindex].nexthop_addr.u.prefix6,
+             sizeof(struct in6_addr));
 
       /*
        * If we are sending v6 secondary assume we receive v6 secondary