summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_clist.c
diff options
context:
space:
mode:
authorNigel Kukard <nkukard@lbsd.net>2017-08-30 11:39:36 +0200
committerNigel Kukard <nkukard@lbsd.net>2017-09-01 01:39:53 +0200
commit0a7dce9b9e82721ebf636a9ead267312425abbe8 (patch)
treeeb4f173085671a017851348f09530fdef8866823 /bgpd/bgp_clist.c
parentbgpd: Fixed potential memory leak if additive is false (diff)
downloadfrr-0a7dce9b9e82721ebf636a9ead267312425abbe8.tar.xz
frr-0a7dce9b9e82721ebf636a9ead267312425abbe8.zip
bgpd: Fixed incorrect calculation of pointer location
com_index_to_delete[i] holds the location in lcom->val of where the value is stored, we cannot just increment it by this value on each iteration as we'll overflow the size of lcom->val. Signed-off-by: Nigel Kukard <nkukard@lbsd.net>
Diffstat (limited to 'bgpd/bgp_clist.c')
-rw-r--r--bgpd/bgp_clist.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c
index 7104f17e5..162ea59a0 100644
--- a/bgpd/bgp_clist.c
+++ b/bgpd/bgp_clist.c
@@ -941,9 +941,8 @@ struct lcommunity *lcommunity_list_match_delete(struct lcommunity *lcom,
}
/* Delete all of the communities we flagged for deletion */
- ptr = lcom->val;
for (i = delete_index - 1; i >= 0; i--) {
- ptr += (com_index_to_delete[i] * LCOMMUNITY_SIZE);
+ ptr = lcom->val + (com_index_to_delete[i] * LCOMMUNITY_SIZE);
lcommunity_del_val(lcom, ptr);
}