]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Check to ensure community attributes exist before freeing them
authorJosh Cox <josh.cox@pureport.com>
Tue, 5 May 2020 17:09:14 +0000 (13:09 -0400)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Wed, 6 May 2020 05:39:47 +0000 (08:39 +0300)
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 432c922ea56dd537c8849a06b146a01e1930adc8..9185eee03a8a2d1985387034473b5bbc40e7f634 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 4c55a0764d2eeef6af7d9cb9f36ed6213c0fd441..b16a209872b188c69fbe829f6f37b21e3908eb31 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 674686b3c449d7df7da366203fbdaeaccc877622..e1e2ac97f9e1c4c75808b6528cdf9bb2370c7d07 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);
        XFREE(MTYPE_LCOMMUNITY, *lcom);