diff options
author | Donatas Abraitis <donatas.abraitis@gmail.com> | 2021-08-16 16:24:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-16 16:24:21 +0200 |
commit | 3af20fda0bc0eb0aecd497ba1412c39e97988c0a (patch) | |
tree | 530736bfbcfa903592953cd5f6c4cc0fbf8785db /bgpd/bgp_routemap.c | |
parent | Merge pull request #9265 from ton31337/fix/extcommunity_lb_route-map_persistent (diff) | |
parent | bgpd: fix memory leaks in bgp_show_table (diff) | |
download | frr-3af20fda0bc0eb0aecd497ba1412c39e97988c0a.tar.xz frr-3af20fda0bc0eb0aecd497ba1412c39e97988c0a.zip |
Merge pull request #9369 from idryzhov/comm-alias-memleaks
bgpd: fix various memleaks when using community aliases
Diffstat (limited to 'bgpd/bgp_routemap.c')
-rw-r--r-- | bgpd/bgp_routemap.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 11333516c..1a14eb0f4 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -1189,27 +1189,38 @@ route_match_alias(void *rule, const struct prefix *prefix, void *object) struct bgp_path_info *path = object; char **communities; int num; + bool found; if (path->attr->community) { + found = false; frrstr_split(path->attr->community->str, " ", &communities, &num); for (int i = 0; i < num; i++) { const char *com2alias = bgp_community2alias(communities[i]); - if (strcmp(alias, com2alias) == 0) - return RMAP_MATCH; + if (!found && strcmp(alias, com2alias) == 0) + found = true; + XFREE(MTYPE_TMP, communities[i]); } + XFREE(MTYPE_TMP, communities); + if (found) + return RMAP_MATCH; } if (path->attr->lcommunity) { + found = false; frrstr_split(path->attr->lcommunity->str, " ", &communities, &num); for (int i = 0; i < num; i++) { const char *com2alias = bgp_community2alias(communities[i]); - if (strcmp(alias, com2alias) == 0) - return RMAP_MATCH; + if (!found && strcmp(alias, com2alias) == 0) + found = false; + XFREE(MTYPE_TMP, communities[i]); } + XFREE(MTYPE_TMP, communities); + if (found) + return RMAP_MATCH; } return RMAP_NOMATCH; |