]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: Fix memory leak of ecommunity_ecom2str
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 16 May 2018 13:54:03 +0000 (09:54 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 16 May 2018 13:59:06 +0000 (09:59 -0400)
The creation of a temporary string for the ecommunity
was being leaked when debugging is enabled.  Write
a bit of code to prevent this.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_ecommunity.c
bgpd/bgp_ecommunity.h
bgpd/bgp_flowspec.c

index 85b9ffd8ca27ea859481c37df30df96d02bf19ea..99fe80f055497d5ebe0fec3050404a5f3340b210 100644 (file)
@@ -52,6 +52,11 @@ struct ecommunity *ecommunity_new(void)
                                            sizeof(struct ecommunity));
 }
 
+void ecommunity_strfree(char **s)
+{
+       XFREE(MTYPE_ECOMMUNITY_STR, *s);
+}
+
 /* Allocate ecommunities.  */
 void ecommunity_free(struct ecommunity **ecom)
 {
index 88bdb5e2ae026cec5f4c64aceca4530c0ceeede7..2f59308d65fd1f0f0eedfbfa9637c61ea0e3da25 100644 (file)
@@ -156,6 +156,7 @@ extern void ecommunity_unintern(struct ecommunity **);
 extern unsigned int ecommunity_hash_make(void *);
 extern struct ecommunity *ecommunity_str2com(const char *, int, int);
 extern char *ecommunity_ecom2str(struct ecommunity *, int, int);
+extern void ecommunity_strfree(char **s);
 extern int ecommunity_match(const struct ecommunity *,
                            const struct ecommunity *);
 extern char *ecommunity_str(struct ecommunity *);
index 5db7e37089bf49e7953b3c2c31536eb71e232d61..6eb1e39884d386233a7ecd6e2f1a762fae213dd5 100644 (file)
@@ -166,6 +166,9 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr,
                                         BGP_FLOWSPEC_NLRI_STRING_MAX,
                                         "EC{%s}",
                                        s == NULL ? "none" : s);
+
+                               if (s)
+                                       ecommunity_strfree(&s);
                        }
                        snprintf(local_string, BGP_FLOWSPEC_NLRI_STRING_MAX,
                                 "FS Rx %s %s %s %s", withdraw ?