From: Renato Westphal Date: Fri, 19 Oct 2018 18:53:55 +0000 (-0300) Subject: bgpd: handle NULL pointers in lcommunity_cmp() X-Git-Tag: frr-7.1-dev~253^2~11 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=fbcdff8229519bce83f34ea327f6000d21c24d61;p=matthieu%2Ffrr.git 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 --- 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); }