]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Check to ensure community attributes exist before freeing them 6350/head
authorJosh Cox <josh.cox@pureport.com>
Tue, 5 May 2020 17:09:14 +0000 (13:09 -0400)
committerJosh Cox <josh.cox@pureport.com>
Tue, 5 May 2020 19:59:38 +0000 (15:59 -0400)
Community attributes might have been removed by an inbound route map, so we
should check to ensure they still exist before trying to free them.
This fixes a segfault described in issue #6345.

Signed-off-by: Josh Cox <josh.cox@pureport.com>
bgpd/bgp_community.c
bgpd/bgp_ecommunity.c
bgpd/bgp_lcommunity.c

index 30de84c878b6291078bf49cc690ccec4c44a032e..0d60fbf47932525980b6869e3ef5e86d90f4c5a9 100644 (file)
@@ -40,6 +40,9 @@ static struct community *community_new(void)
 /* Free communities value.  */
 void community_free(struct community **com)
 {
+       if (!(*com))
+               return;
+
        XFREE(MTYPE_COMMUNITY_VAL, (*com)->val);
        XFREE(MTYPE_COMMUNITY_STR, (*com)->str);
 
index 062a6477fa8315128597fa19528e4ca5ae0d540c..d13da74b047ae383e5a41b0508a68de0061ceb8b 100644 (file)
@@ -59,6 +59,9 @@ void ecommunity_strfree(char **s)
 /* Allocate ecommunities.  */
 void ecommunity_free(struct ecommunity **ecom)
 {
+       if (!(*ecom))
+               return;
+
        XFREE(MTYPE_ECOMMUNITY_VAL, (*ecom)->val);
        XFREE(MTYPE_ECOMMUNITY_STR, (*ecom)->str);
        XFREE(MTYPE_ECOMMUNITY, *ecom);
index f47ae91663ed5cd90a10226210558a055ff63c13..5900fcf862b91c2ab6c4d710be4ea55ee06ac17d 100644 (file)
@@ -44,6 +44,9 @@ static struct lcommunity *lcommunity_new(void)
 /* Allocate lcommunities.  */
 void lcommunity_free(struct lcommunity **lcom)
 {
+       if (!(*lcom))
+               return;
+
        XFREE(MTYPE_LCOMMUNITY_VAL, (*lcom)->val);
        XFREE(MTYPE_LCOMMUNITY_STR, (*lcom)->str);
        if ((*lcom)->json)