summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2020-04-15 14:19:16 -0400
committerGitHub <noreply@github.com>2020-04-15 14:19:16 -0400
commitee215461ac7e8bec84691359c7a64488a8c0ee59 (patch)
tree1d00e11fd36af6e3b9144f44a7b307fc99a46b8e
parent7c6bcbe652ec8e757a8c3b62fe3015a24dbb22f7 (diff)
parentbc2c9ae68c7e9c4a2b301f648862ec0ff885f658 (diff)
Merge pull request #6232 from ton31337/fix/validate_lcommunities
bgpd: Validate all large communities if specified more per line
-rw-r--r--bgpd/bgp_clist.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c
index cf4d44ea22..1361ef99be 100644
--- a/bgpd/bgp_clist.c
+++ b/bgpd/bgp_clist.c
@@ -1090,26 +1090,34 @@ struct lcommunity *lcommunity_list_match_delete(struct lcommunity *lcom,
/* Helper to check if every octet do not exceed UINT_MAX */
static bool lcommunity_list_valid(const char *community)
{
- int octets = 0;
- char **splits;
- int num;
+ int octets;
+ char **splits, **communities;
+ int num, num_communities;
- frrstr_split(community, ":", &splits, &num);
+ frrstr_split(community, " ", &communities, &num_communities);
- for (int i = 0; i < num; i++) {
- if (strtoul(splits[i], NULL, 10) > UINT_MAX)
- return false;
+ for (int j = 0; j < num_communities; j++) {
+ octets = 0;
+ frrstr_split(communities[j], ":", &splits, &num);
+
+ for (int i = 0; i < num; i++) {
+ if (strtoul(splits[i], NULL, 10) > UINT_MAX)
+ return false;
- if (strlen(splits[i]) == 0)
+ if (strlen(splits[i]) == 0)
+ return false;
+
+ octets++;
+ XFREE(MTYPE_TMP, splits[i]);
+ }
+ XFREE(MTYPE_TMP, splits);
+
+ if (octets < 3)
return false;
- octets++;
- XFREE(MTYPE_TMP, splits[i]);
+ XFREE(MTYPE_TMP, communities[j]);
}
- XFREE(MTYPE_TMP, splits);
-
- if (octets < 3)
- return false;
+ XFREE(MTYPE_TMP, communities);
return true;
}