diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2010-04-26 08:46:32 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2010-04-26 08:46:32 +0000 |
commit | 19b613f30bc55b25331d2f2f7ac8519250560b40 (patch) | |
tree | 66418b43ecb3f69521d7b5db839b436f6be9c316 /usr.sbin | |
parent | cde3e380bfecc50fb439d29181799ca1bdc83cbd (diff) |
Fix some memory leaks on config reload failure and move one particular
cleanup loop to parse.y where it belongs.
OK henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpd/bgpd.c | 6 | ||||
-rw-r--r-- | usr.sbin/bgpd/parse.y | 11 |
2 files changed, 11 insertions, 6 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index 346c8443f4f..f6227c98f7a 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.158 2010/04/22 08:24:58 claudio Exp $ */ +/* $OpenBSD: bgpd.c,v 1.159 2010/04/26 08:46:31 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -434,10 +434,6 @@ reconfigure(char *conffile, struct bgpd_config *conf, struct mrt_head *mrt_l, if (parse_config(conffile, conf, mrt_l, peer_l, &net_l, &rules_l)) { log_warnx("config file %s has errors, not reloading", conffile); - while ((rr = SIMPLEQ_FIRST(&ribnames))) { - SIMPLEQ_REMOVE_HEAD(&ribnames, entry); - free(rr); - } return (1); } diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y index 0731a460a4e..1d9c7ee23c0 100644 --- a/usr.sbin/bgpd/parse.y +++ b/usr.sbin/bgpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.250 2010/03/31 18:53:23 claudio Exp $ */ +/* $OpenBSD: parse.y,v 1.251 2010/04/26 08:46:31 claudio Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -2335,6 +2335,7 @@ parse_config(char *filename, struct bgpd_config *xconf, struct listen_addr *la; struct network *n; struct filter_rule *r; + struct rde_rib *rr; int errors = 0; if ((conf = calloc(1, sizeof(struct bgpd_config))) == NULL) @@ -2411,23 +2412,31 @@ parse_config(char *filename, struct bgpd_config *xconf, while ((n = TAILQ_FIRST(netconf)) != NULL) { TAILQ_REMOVE(netconf, n, entry); + filterset_free(&n->net.attrset); free(n); } while ((r = TAILQ_FIRST(filter_l)) != NULL) { TAILQ_REMOVE(filter_l, r, entry); + filterset_free(&r->set); free(r); } while ((r = TAILQ_FIRST(peerfilter_l)) != NULL) { TAILQ_REMOVE(peerfilter_l, r, entry); + filterset_free(&r->set); free(r); } while ((r = TAILQ_FIRST(groupfilter_l)) != NULL) { TAILQ_REMOVE(groupfilter_l, r, entry); + filterset_free(&r->set); free(r); } + while ((rr = SIMPLEQ_FIRST(&ribnames)) != NULL) { + SIMPLEQ_REMOVE_HEAD(&ribnames, entry); + free(rr); + } } else { errors += merge_config(xconf, conf, peer_l, listen_addrs); errors += mrt_mergeconfig(xmconf, mrtconf); |