bgpd: Validate as-path in show bgp regexp

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
This commit is contained in:
Donatas Abraitis 2019-04-18 10:17:57 +03:00
parent f799ea3f94
commit c39008533c
3 changed files with 8 additions and 1 deletions

View File

@ -389,7 +389,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_^|[,{}() ]$*+.?-\\";

View File

@ -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 */

View File

@ -9985,6 +9985,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);