]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: handle NULL pointers in lcommunity_cmp()
authorRenato Westphal <renato@opensourcerouting.org>
Fri, 19 Oct 2018 18:53:55 +0000 (15:53 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Mon, 17 Dec 2018 14:14:04 +0000 (12:14 -0200)
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 <renato@opensourcerouting.org>
bgpd/bgp_lcommunity.c

index 3e160bc56ed95b55d65dbe113400c810dcc04c61..2106b9d521ecc2a8057b7d6a4e72cc4c8fcd023b 100644 (file)
@@ -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);
 }