From 98280b73e5a0c43f00a33dce5d0671f489bb2a67 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 7 Feb 2017 14:34:37 -0500 Subject: [PATCH 1/6] bgpd: Fix uninitialized data Calling zapi_ipv[4|6]_route assumes we set the instance appropriately. Signed-off-by: Donald Sharp --- bgpd/rfapi/vnc_zebra.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c index 85baa13301..23b6e9dbb4 100644 --- a/bgpd/rfapi/vnc_zebra.c +++ b/bgpd/rfapi/vnc_zebra.c @@ -546,6 +546,7 @@ vnc_zebra_route_msg ( api.nexthop_num = nhp_count; api.nexthop = nhp_ary; api.ifindex_num = 0; + api.instance = 0; if (BGP_DEBUG (zebra, ZEBRA)) { @@ -580,6 +581,7 @@ vnc_zebra_route_msg ( SET_FLAG (api.message, ZAPI_MESSAGE_IFINDEX); api.ifindex_num = 1; api.ifindex = &ifindex; + api.instance = 0; if (BGP_DEBUG (zebra, ZEBRA)) { From bf97380cf18495fc5ee3464cc01b942ec106ebc1 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 7 Feb 2017 14:48:45 -0500 Subject: [PATCH 2/6] bgpd: Fix passage of uninitialized value to skiplist_next Signed-off-by: Donald Sharp --- bgpd/rfapi/rfapi_ap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bgpd/rfapi/rfapi_ap.c b/bgpd/rfapi/rfapi_ap.c index 5cc1dd7815..68292c26b1 100644 --- a/bgpd/rfapi/rfapi_ap.c +++ b/bgpd/rfapi/rfapi_ap.c @@ -169,7 +169,7 @@ void rfapiApReadvertiseAll (struct bgp *bgp, struct rfapi_descriptor *rfd) { struct rfapi_adb *adb; - void *cursor; + void *cursor = NULL; int rc; for (rc = From 517cd68a3e308c69c15db6d707f62854e5379033 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 7 Feb 2017 14:55:39 -0500 Subject: [PATCH 3/6] bgpd: Fix usage of uninitialized dn_flag[] dn_flag was tested inside of a 'use_json' block further down in the function. Move initialization of the value to outside of the !use_json if statement Signed-off-by: Donald Sharp --- bgpd/bgp_vty.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 51839b784b..c17bb66846 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -7337,6 +7337,10 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js if (use_json) json_neigh = json_object_new_object(); + memset (dn_flag, '\0', sizeof (dn_flag)); + if (!p->conf_if && peer_dynamic_neighbor (p)) + dn_flag[0] = '*'; + if (!use_json) { if (p->conf_if) /* Configured interface name. */ @@ -7344,13 +7348,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js BGP_PEER_SU_UNSPEC(p) ? "None" : sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); else /* Configured IP address. */ - { - memset(dn_flag, '\0', sizeof(dn_flag)); - if (peer_dynamic_neighbor(p)) - dn_flag[0] = '*'; - vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host); - } } if (use_json) From 90d84f92ae9eb9e277b0669fdc830195c71b0fa8 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 7 Feb 2017 15:08:56 -0500 Subject: [PATCH 4/6] pimd: Cleanup dest buffer to small Cleanup the in_ifname and out_ifname buffers to be large enough to hold the actual interface names. Additionally move the common variables to be defined once, instead of inside of multiple for loops Signed-off-by: Donald Sharp --- pimd/pim_cmd.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 7f276b22ce..ae23499d97 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -2876,6 +2876,13 @@ static void show_mroute(struct vty *vty, u_char uj) json_object *json_ifp_out = NULL; int found_oif = 0; int first = 1; + char grp_str[INET_ADDRSTRLEN]; + char src_str[INET_ADDRSTRLEN]; + char in_ifname[INTERFACE_NAMSIZ+1]; + char out_ifname[INTERFACE_NAMSIZ+1]; + int oif_vif_index; + struct interface *ifp_in; + char proto[100]; if (uj) { json = json_object_new_object(); @@ -2888,13 +2895,6 @@ static void show_mroute(struct vty *vty, u_char uj) /* print list of PIM and IGMP routes */ for (ALL_LIST_ELEMENTS_RO(pim_channel_oil_list, node, c_oil)) { - char grp_str[INET_ADDRSTRLEN]; - char src_str[INET_ADDRSTRLEN]; - char in_ifname[16]; - char out_ifname[16]; - int oif_vif_index; - char proto[100]; - struct interface *ifp_in; found_oif = 0; first = 1; if (!c_oil->installed && !uj) @@ -3034,13 +3034,6 @@ static void show_mroute(struct vty *vty, u_char uj) /* Print list of static routes */ for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) { - char grp_str[INET_ADDRSTRLEN]; - char src_str[INET_ADDRSTRLEN]; - char in_ifname[INTERFACE_NAMSIZ+1]; - char out_ifname[INTERFACE_NAMSIZ+1]; - int oif_vif_index; - struct interface *ifp_in; - char proto[100]; first = 1; if (!s_route->c_oil.installed) From 95c54276f76cd6b9bc628c2a484d9937813324ed Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 8 Feb 2017 08:26:07 -0500 Subject: [PATCH 5/6] zebra: Don't leak socket with failure condition Don't leak a socket when we are unable to set it as non-blocking and warn the user as appropriate. Signed-off-by: Donald Sharp --- zebra/zebra_ptm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index 446eb4953b..bc924842d4 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -388,7 +388,13 @@ zebra_ptm_socket_init (void) if (sock < 0) return -1; if (set_nonblocking(sock) < 0) - return -1; + { + if (IS_ZEBRA_DEBUG_EVENT) + zlog_debug ("%s: Unable to set socket non blocking[%s]", + __PRETTY_FUNCTION__, safe_strerror (errno)); + close (sock); + return -1; + } /* Make server socket. */ memset (&addr, 0, sizeof (struct sockaddr_un)); From 74ef1672285135d630356054eba5491cdbaa5186 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 8 Feb 2017 09:35:33 -0500 Subject: [PATCH 6/6] bgpd: Fix miss-indented code. Signed-off-by: Donald Sharp --- bgpd/bgp_vty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index c17bb66846..01d1768691 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -7348,7 +7348,7 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js BGP_PEER_SU_UNSPEC(p) ? "None" : sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); else /* Configured IP address. */ - vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host); + vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host); } if (use_json)