Skip to content

Commit

Permalink
bgpd: Validate as-path in show bgp regexp
Browse files Browse the repository at this point in the history
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
  • Loading branch information
ton31337 committed Apr 23, 2019
1 parent 194cf1c commit b36a179
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bgpd/bgp_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ static int as_list_dup_check(struct as_list *aslist, struct as_filter *new)
return 0;
}

static int config_bgp_aspath_validate(const char *regstr)
int config_bgp_aspath_validate(const char *regstr)
{
char valid_chars[] = "1234567890_^|[,{}() ]$*+.?-\\";

Expand Down
1 change: 1 addition & 0 deletions bgpd/bgp_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ extern enum as_filter_type as_list_apply(struct as_list *, void *);
extern struct as_list *as_list_lookup(const char *);
extern void as_list_add_hook(void (*func)(char *));
extern void as_list_delete_hook(void (*func)(const char *));
extern int config_bgp_aspath_validate(const char *regstr);

#endif /* _QUAGGA_BGP_FILTER_H */
6 changes: 6 additions & 0 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -9703,6 +9703,12 @@ static int bgp_show_regexp(struct vty *vty, struct bgp *bgp, const char *regstr,
regex_t *regex;
int rc;

if (!config_bgp_aspath_validate(regstr)) {
vty_out(vty, "Invalid character in as-path access-list %s\n",
regstr);
return CMD_WARNING_CONFIG_FAILED;
}

regex = bgp_regcomp(regstr);
if (!regex) {
vty_out(vty, "Can't compile regexp %s\n", regstr);
Expand Down

0 comments on commit b36a179

Please sign in to comment.