diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2018-09-09 20:39:10 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2018-09-09 20:39:10 +0000 |
commit | 8756dfbd59891ac5c9051b2cb2bac7fe13126483 (patch) | |
tree | 087529676ec72ebbe0136f5450655dbea732efe2 /usr.sbin | |
parent | bcb7871460f270d955dd5e40e85e83da80064ec1 (diff) |
Allow for empty as-set and prefix-set definitions by adding explicit rules
for those because shift/reduce issues in the list with optional commas.
OK benno@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpd/parse.y | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y index fae82a22ad4..4d5861f5b54 100644 --- a/usr.sbin/bgpd/parse.y +++ b/usr.sbin/bgpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.348 2018/09/09 15:04:36 claudio Exp $ */ +/* $OpenBSD: parse.y,v 1.349 2018/09/09 20:39:09 claudio Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -408,6 +408,11 @@ as_set : ASSET STRING '{' optnl { } as_set_l optnl '}' { done_as_set(); } + | ASSET STRING '{' optnl '}' { + if (new_as_set($2) != 0) + YYERROR; + free($2); + } as_set_l : as4number_any { add_as_set($1); } | as_set_l comma as4number_any { add_as_set($3); } @@ -432,6 +437,25 @@ prefixset : PREFIXSET STRING '{' optnl { SIMPLEQ_INSERT_TAIL(conf->prefixsets, curpset, entry); curpset = NULL; } + | PREFIXSET STRING '{' optnl '}' { + if (find_prefixset($2, conf->prefixsets) != NULL) { + yyerror("duplicate prefixset %s", $2); + free($2); + YYERROR; + } + if ((curpset = calloc(1, sizeof(*curpset))) == NULL) + fatal("prefixset"); + if (strlcpy(curpset->name, $2, sizeof(curpset->name)) >= + sizeof(curpset->name)) { + yyerror("prefix-set \"%s\" too long: max %zu", + $2, sizeof(curpset->name) - 1); + free($2); + YYERROR; + } + SIMPLEQ_INIT(&curpset->psitems); + SIMPLEQ_INSERT_TAIL(conf->prefixsets, curpset, entry); + curpset = NULL; + } prefixset_l : prefixset_item { SIMPLEQ_INSERT_TAIL(&curpset->psitems, $1, entry); |