Skip to content

Commit

Permalink
pimd: Fix various sizeof and buffer length issues
Browse files Browse the repository at this point in the history
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
  • Loading branch information
donaldsharp committed Apr 6, 2017
1 parent 0963981 commit 4390fb9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
12 changes: 8 additions & 4 deletions pimd/pim_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pimd/pim_tlv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions pimd/pim_zlookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4390fb9

Please sign in to comment.