summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2005-03-29 11:13:34 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2005-03-29 11:13:34 +0000
commita48f22beb00c28eed9da554cbc9ce41d95405cf0 (patch)
tree9baec7be3218072cb3c231e6a8716562df8ac9f1 /usr.sbin
parentf0ce9bfd071ae39796326317d695b910dbd341e2 (diff)
walk & free network and filter lists after parse errors
ok claudio theo
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/parse.y22
1 files changed, 18 insertions, 4 deletions
diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y
index ff4828dfb27..2a860e7e555 100644
--- a/usr.sbin/bgpd/parse.y
+++ b/usr.sbin/bgpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.155 2005/03/28 15:39:32 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.156 2005/03/29 11:13:33 henning Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -1630,6 +1630,8 @@ parse_config(char *filename, struct bgpd_config *xconf,
struct sym *sym, *next;
struct peer *p, *pnext;
struct listen_addr *la;
+ struct network *n;
+ struct filter_rule *r;
if ((fin = fopen(filename, "r")) == NULL) {
warn("%s", filename);
@@ -1649,8 +1651,6 @@ parse_config(char *filename, struct bgpd_config *xconf,
if ((listen_addrs = calloc(1, sizeof(struct listen_addrs))) == NULL)
fatal(NULL);
LIST_INIT(mrtconf);
- netconf = nc;
- TAILQ_INIT(netconf);
TAILQ_INIT(listen_addrs);
peer_l = NULL;
@@ -1660,9 +1660,13 @@ parse_config(char *filename, struct bgpd_config *xconf,
lineno = 1;
errors = 0;
id = 1;
+ conf->opts = xconf->opts;
+
+ /* filter and network list are always empty in the parent */
filter_l = xfilter_l;
TAILQ_INIT(filter_l);
- conf->opts = xconf->opts;
+ netconf = nc;
+ TAILQ_INIT(netconf);
yyparse();
@@ -1694,6 +1698,16 @@ parse_config(char *filename, struct bgpd_config *xconf,
pnext = p->next;
free(p);
}
+
+ while ((n = TAILQ_FIRST(netconf)) != NULL) {
+ TAILQ_REMOVE(netconf, n, entry);
+ free(n);
+ }
+
+ while ((r = TAILQ_FIRST(filter_l)) != NULL) {
+ TAILQ_REMOVE(filter_l, r, entry);
+ free(r);
+ }
} else {
errors += merge_config(xconf, conf, peer_l, listen_addrs);
errors += mrt_mergeconfig(xmconf, mrtconf);