From: Nigel Kukard Date: Thu, 31 Aug 2017 09:27:46 +0000 (+0000) Subject: bgpd: Fixed pointer arithmatic miscalculation X-Git-Tag: frr-4.0-dev~348^2~4 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=3ac053e608b63041afbf0080f03670d4b56e7fef;p=mirror%2Ffrr.git bgpd: Fixed pointer arithmatic miscalculation If we increment PTR by i * size each time, we end up doing 1, 3, 6 etc. Signed-off-by: Nigel Kukard --- diff --git a/bgpd/bgp_lcommunity.c b/bgpd/bgp_lcommunity.c index fd734b2c5b..f464e7122d 100644 --- a/bgpd/bgp_lcommunity.c +++ b/bgpd/bgp_lcommunity.c @@ -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; }