]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: OoB access (Coverity 1448806, 1448810)
authorpaco <paco@voltanet.io>
Tue, 12 Jun 2018 17:16:39 +0000 (19:16 +0200)
committerpaco <paco@voltanet.io>
Tue, 12 Jun 2018 17:26:13 +0000 (19:26 +0200)
Signed-off-by: F. Aragon <paco@voltanet.io>
lib/prefix.c

index ead5444fd0a3b558856d24d209b371d66cff477f..ed0774e77495b03415aef24c2f5d524d3e0fe1dd 100644 (file)
@@ -584,8 +584,8 @@ int prefix_match(const struct prefix *n, const struct prefix *p)
        }
 
        /* Set both prefix's head pointer. */
-       np = (const uint8_t *)&n->u.prefix;
-       pp = (const uint8_t *)&p->u.prefix;
+       np = n->u.val;
+       pp = p->u.val;
 
        offset = n->prefixlen / PNBBY;
        shift = n->prefixlen % PNBBY;
@@ -609,8 +609,8 @@ int prefix_match_network_statement(const struct prefix *n,
        const uint8_t *np, *pp;
 
        /* Set both prefix's head pointer. */
-       np = (const uint8_t *)&n->u.prefix;
-       pp = (const uint8_t *)&p->u.prefix;
+       np = n->u.val;
+       pp = p->u.val;
 
        offset = n->prefixlen / PNBBY;
        shift = n->prefixlen % PNBBY;
@@ -742,8 +742,8 @@ int prefix_cmp(const struct prefix *p1, const struct prefix *p2)
                                return 1;
                return 0;
        }
-       pp1 = (const uint8_t *)&p1->u.prefix;
-       pp2 = (const uint8_t *)&p2->u.prefix;
+       pp1 = p1->u.val;
+       pp2 = p2->u.val;
 
        if (p1->prefixlen != p2->prefixlen)
                return 1;
@@ -774,8 +774,8 @@ int prefix_common_bits(const struct prefix *p1, const struct prefix *p2)
        uint8_t xor ;
 
        /* Set both prefix's head pointer. */
-       const uint8_t *pp1 = (const uint8_t *)&p1->u.prefix;
-       const uint8_t *pp2 = (const uint8_t *)&p2->u.prefix;
+       const uint8_t *pp1 = p1->u.val;
+       const uint8_t *pp2 = p2->u.val;
 
        if (p1->family == AF_INET)
                length = IPV4_MAX_BYTELEN;