From a48f22beb00c28eed9da554cbc9ce41d95405cf0 Mon Sep 17 00:00:00 2001 From: Henning Brauer Date: Tue, 29 Mar 2005 11:13:34 +0000 Subject: walk & free network and filter lists after parse errors ok claudio theo --- usr.sbin/bgpd/parse.y | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'usr.sbin/bgpd') 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 @@ -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); -- cgit v1.2.3