]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Fixed pointer arithmatic miscalculation
authorNigel Kukard <nkukard@lbsd.net>
Thu, 31 Aug 2017 09:27:46 +0000 (09:27 +0000)
committerNigel Kukard <nkukard@lbsd.net>
Sun, 3 Sep 2017 03:53:04 +0000 (03:53 +0000)
If we increment PTR by i * size each time, we end up doing 1, 3, 6
etc.

Signed-off-by: Nigel Kukard <nkukard@lbsd.net>
bgpd/bgp_lcommunity.c

index 9de370da44ee198ad11ec5a283ec1f51817499ca..ac90a421d1e6ea7ed646625f68b2052d3626251a 100644 (file)
@@ -400,9 +400,8 @@ int lcommunity_include(struct lcommunity *lcom, u_char *ptr)
        int i;
        u_char *lcom_ptr;
 
-       lcom_ptr = lcom->val;
        for (i = 0; i < lcom->size; i++) {
-               lcom_ptr += (i * LCOMMUNITY_SIZE);
+               lcom_ptr = lcom->val + (i * LCOMMUNITY_SIZE);
                if (memcmp(ptr, lcom_ptr, LCOMMUNITY_SIZE) == 0)
                        return 1;
        }