Browse Source

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 <sharpd@cumulusnetworks.com>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Donald Sharp 2 years ago
parent
commit
c96e78dde1
4 changed files with 6 additions and 12 deletions
  1. 1 0
      pimd/pim_iface.c
  2. 5 2
      pimd/pim_ifchannel.c
  3. 0 5
      pimd/pim_igmpv3.c
  4. 0 5
      pimd/pim_pim.c

+ 1 - 0
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();

+ 5 - 2
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);
 

+ 0 - 5
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,

+ 0 - 5
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) {