From fbcdff8229519bce83f34ea327f6000d21c24d61 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Fri, 19 Oct 2018 15:53:55 -0300 Subject: [PATCH] bgpd: handle NULL pointers in lcommunity_cmp() Like community_cmp() and ecommunity_cmp(), the lcommunity_cmp() function also needs to handle NULL pointers for correct operation. Without this fix, bgpd can crash when entering the following commands: vtysh -c "configure terminal" -c "ip large-community-list standard WORD deny" vtysh -c "configure terminal" -c "no ip large-community-list expanded WORD" Signed-off-by: Renato Westphal --- bgpd/bgp_lcommunity.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bgpd/bgp_lcommunity.c b/bgpd/bgp_lcommunity.c index 3e160bc56e..2106b9d521 100644 --- a/bgpd/bgp_lcommunity.c +++ b/bgpd/bgp_lcommunity.c @@ -318,6 +318,12 @@ int lcommunity_cmp(const void *arg1, const void *arg2) const struct lcommunity *lcom1 = arg1; const struct lcommunity *lcom2 = arg2; + if (lcom1 == NULL && lcom2 == NULL) + return 1; + + if (lcom1 == NULL || lcom2 == NULL) + return 0; + return (lcom1->size == lcom2->size && memcmp(lcom1->val, lcom2->val, lcom_length(lcom1)) == 0); } -- 2.39.5