Browse Source

quagga: Additional centos 6 -enable-werror fixes

This commit fixes these warnings:

1) bgpd/bgp_nexthop.c - dereferencing pointer 'X' does break strict-aliasing rules
2) pimd/pim_igmp_join.c - dereferencing pointer 'X' does break strict-aliasing rules
3) ripd/ripd.c - 'ifaddr.prefixlen' may be used uninitialized in this function

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Donald Sharp 6 years ago
parent
commit
26a18eb223
3 changed files with 16 additions and 15 deletions
  1. 2 4
      bgpd/bgp_nexthop.c
  2. 12 10
      pimd/pim_igmp_join.c
  3. 2 1
      ripd/ripd.c

+ 2 - 4
bgpd/bgp_nexthop.c

@@ -648,9 +648,9 @@ bgp_connected_add (struct connected *ifc)
 
   addr = ifc->address;
 
+  p = *(CONNECTED_PREFIX(ifc));
   if (addr->family == AF_INET)
     {
-      PREFIX_COPY_IPV4(&p, CONNECTED_PREFIX(ifc));
       apply_mask_ipv4 ((struct prefix_ipv4 *) &p);
 
       if (prefix_ipv4_any ((struct prefix_ipv4 *) &p))
@@ -674,7 +674,6 @@ bgp_connected_add (struct connected *ifc)
 #ifdef HAVE_IPV6
   else if (addr->family == AF_INET6)
     {
-      PREFIX_COPY_IPV6(&p, CONNECTED_PREFIX(ifc));
       apply_mask_ipv6 ((struct prefix_ipv6 *) &p);
 
       if (IN6_IS_ADDR_UNSPECIFIED (&p.u.prefix6))
@@ -715,9 +714,9 @@ bgp_connected_delete (struct connected *ifc)
 
   addr = ifc->address;
 
+  p = *(CONNECTED_PREFIX(ifc));
   if (addr->family == AF_INET)
     {
-      PREFIX_COPY_IPV4(&p, CONNECTED_PREFIX(ifc));
       apply_mask_ipv4 ((struct prefix_ipv4 *) &p);
 
       if (prefix_ipv4_any ((struct prefix_ipv4 *) &p))
@@ -742,7 +741,6 @@ bgp_connected_delete (struct connected *ifc)
 #ifdef HAVE_IPV6
   else if (addr->family == AF_INET6)
     {
-      PREFIX_COPY_IPV6(&p, CONNECTED_PREFIX(ifc));
       apply_mask_ipv6 ((struct prefix_ipv6 *) &p);
 
       if (IN6_IS_ADDR_UNSPECIFIED (&p.u.prefix6))

+ 12 - 10
pimd/pim_igmp_join.c

@@ -45,18 +45,20 @@ int pim_igmp_join_source(int fd, int ifindex,
 			 struct in_addr source_addr)
 {
   struct group_source_req req;
-  struct sockaddr_in *group_sa = (struct sockaddr_in *) &req.gsr_group;
-  struct sockaddr_in *source_sa = (struct sockaddr_in *) &req.gsr_source;
+  struct sockaddr_in group;
+  struct sockaddr_in source;
 
-  memset(group_sa, 0, sizeof(*group_sa));
-  group_sa->sin_family = AF_INET;
-  group_sa->sin_addr = group_addr;
-  group_sa->sin_port = htons(0);
+  memset(&group, 0, sizeof(group));
+  group.sin_family = AF_INET;
+  group.sin_addr = group_addr;
+  group.sin_port = htons(0);
+  memcpy(&req.gsr_group, &group, sizeof(struct sockaddr_in));
 
-  memset(source_sa, 0, sizeof(*source_sa));
-  source_sa->sin_family = AF_INET;
-  source_sa->sin_addr = source_addr;
-  source_sa->sin_port = htons(0);
+  memset(&source, 0, sizeof(source));
+  source.sin_family = AF_INET;
+  source.sin_addr = source_addr;
+  source.sin_port = htons(0);
+  memcpy(&req.gsr_source, &source, sizeof(struct sockaddr_in));
 
   req.gsr_interface = ifindex;
 

+ 2 - 1
ripd/ripd.c

@@ -1168,7 +1168,8 @@ rip_response_process (struct rip_packet *packet, int size,
   struct prefix_ipv4 ifaddr;
   struct prefix_ipv4 ifaddrclass;
   int subnetted;
-      
+
+  memset(&ifaddr, 0, sizeof(ifaddr));
   /* We don't know yet. */
   subnetted = -1;