From 90556ee7555804ac303f0abd920b33138e0c2ad3 Mon Sep 17 00:00:00 2001 From: claudio Date: Sun, 9 Sep 2018 20:39:09 +0000 Subject: [PATCH] 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@ --- usr.sbin/bgpd/parse.y | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) 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 @@ -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); -- 2.20.1