]> 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>
Thu, 31 Aug 2017 23:39:53 +0000 (23:39 +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 fd734b2c5b639dffda56763fae249db177d44f21..f464e7122d12e94fe91bc86629987a494ce7c5ba 100644 (file)
@@ -398,9 +398,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;
        }