[quagga-dev,15511,1/2] pimd: Fix of using uninitialized Memory

Message ID 1465500900-29084-1-git-send-email-sharpd@cumulusnetworks.com
State Under Review
Headers show
Series
  • [quagga-dev,15511,1/2] pimd: Fix of using uninitialized Memory
Related show

Commit Message

Donald Sharp June 9, 2016, 7:34 p.m.
Valgrind is reporting that pimd is using uninitialized
memory for comparisons.  This commit addresses
the issues found there.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
---
 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(-)

Patch hide | download patch | download mbox

diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c
index 2533d0f..ddad6cb 100644
--- a/pimd/pim_iface.c
+++ b/pimd/pim_iface.c
@@ -107,6 +107,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 e801f4e..ad97879 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 3657f2f..e5001f7 100644
--- a/pimd/pim_igmpv3.c
+++ b/pimd/pim_igmpv3.c
@@ -1670,14 +1670,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 c522475..c52b0d3 100644
--- a/pimd/pim_pim.c
+++ b/pimd/pim_pim.c
@@ -473,14 +473,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) {