]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: address type-punned pointers in prefix_same()
authorDenis Ovsienko <infrastation@yandex.ru>
Sun, 18 Dec 2011 11:40:17 +0000 (15:40 +0400)
committerDenis Ovsienko <infrastation@yandex.ru>
Mon, 2 Jan 2012 14:37:54 +0000 (18:37 +0400)
IPV4_ADDR_SAME() wasn't passed the right union member, this could cause
a bug due to strict-aliasing. IPV6_ADDR_SAME() case got its fix before
the error could be created by macro upgrade.

lib/prefix.c

index 580ba31a4e41ba1a900439f21943e500bbd2b332..1b1c6626717573fef1093366829b0f5de3a5d961 100644 (file)
@@ -2411,11 +2411,11 @@ prefix_same (const struct prefix *p1, const struct prefix *p2)
   if (p1->family == p2->family && p1->prefixlen == p2->prefixlen)
     {
       if (p1->family == AF_INET)
-       if (IPV4_ADDR_SAME (&p1->u.prefix, &p2->u.prefix))
+       if (IPV4_ADDR_SAME (&p1->u.prefix4.s_addr, &p2->u.prefix4.s_addr))
          return 1;
 #ifdef HAVE_IPV6
       if (p1->family == AF_INET6 )
-       if (IPV6_ADDR_SAME (&p1->u.prefix, &p2->u.prefix))
+       if (IPV6_ADDR_SAME (&p1->u.prefix6.s6_addr, &p2->u.prefix6.s6_addr))
          return 1;
 #endif /* HAVE_IPV6 */
     }