From e4cc018527fa9ef187798b416d43253b936c5b89 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 9 Jun 2016 15:16:14 -0400 Subject: [PATCH] pimd: Fix of using uninitialized Memory Valgrind is reporting that pimd is using uninitialized memory for comparisons. This commit addresses the issues found there. Signed-off-by: Donald Sharp --- pimd/pim_iface.c | 1 + pimd/pim_ifchannel.c | 7 +++++-- pimd/pim_igmpv3.c | 5 ----- pimd/pim_pim.c | 5 ----- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index 985a7588a7..b70cd4b033 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -115,6 +115,7 @@ struct pim_interface *pim_if_new(struct interface *ifp, int igmp, int pim) pim_ifp->igmp_socket_list = 0; pim_ifp->pim_neighbor_list = 0; pim_ifp->pim_ifchannel_list = 0; + pim_ifp->pim_generation_id = 0; /* list of struct igmp_sock */ pim_ifp->igmp_socket_list = list_new(); diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index e801f4eeb5..ad97879d6d 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -223,6 +223,11 @@ static struct pim_ifchannel *pim_ifchannel_new(struct interface *ifp, ch->t_ifjoin_prune_pending_timer = 0; ch->ifjoin_creation = 0; + ch->ifassert_my_metric = pim_macro_ch_my_assert_metric_eval(ch); + ch->ifassert_winner_metric = pim_macro_ch_my_assert_metric_eval (ch); + + ch->ifassert_winner.s_addr = 0; + /* Assert state */ ch->t_ifassert_timer = 0; reset_ifassert_state(ch); @@ -236,8 +241,6 @@ static struct pim_ifchannel *pim_ifchannel_new(struct interface *ifp, else PIM_IF_FLAG_UNSET_ASSERT_TRACKING_DESIRED(ch->flags); - ch->ifassert_my_metric = pim_macro_ch_my_assert_metric_eval(ch); - /* Attach to list */ listnode_add(pim_ifp->pim_ifchannel_list, ch); diff --git a/pimd/pim_igmpv3.c b/pimd/pim_igmpv3.c index 8a32a32729..180de9d71e 100644 --- a/pimd/pim_igmpv3.c +++ b/pimd/pim_igmpv3.c @@ -1661,14 +1661,9 @@ void pim_igmp_send_membership_query(struct igmp_group *group, querier_query_interval, qqic, checksum); } -#if 0 memset(&to, 0, sizeof(to)); -#endif to.sin_family = AF_INET; to.sin_addr = dst_addr; -#if 0 - to.sin_port = htons(0); -#endif tolen = sizeof(to); sent = sendto(fd, query_buf, msg_size, MSG_DONTWAIT, diff --git a/pimd/pim_pim.c b/pimd/pim_pim.c index 5912709fe6..a492d57db5 100644 --- a/pimd/pim_pim.c +++ b/pimd/pim_pim.c @@ -481,14 +481,9 @@ int pim_msg_send(int fd, *(uint16_t *) PIM_MSG_HDR_OFFSET_CHECKSUM(pim_msg)); } -#if 0 memset(&to, 0, sizeof(to)); -#endif to.sin_family = AF_INET; to.sin_addr = dst; -#if 0 - to.sin_port = htons(0); -#endif tolen = sizeof(to); if (PIM_DEBUG_PIM_PACKETDUMP_SEND) { -- 2.39.5