From 3ac053e608b63041afbf0080f03670d4b56e7fef Mon Sep 17 00:00:00 2001 From: Nigel Kukard Date: Thu, 31 Aug 2017 09:27:46 +0000 Subject: [PATCH] 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 --- bgpd/bgp_lcommunity.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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; } -- 2.39.5