summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd/bgpd.c
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2010-01-11 05:47:52 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2010-01-11 05:47:52 +0000
commit0ba010ae1ef3e0246ed01cbad16714780b943605 (patch)
treed13522ff5d1129e83cc28260216fb9bb44a1aeb3 /usr.sbin/bgpd/bgpd.c
parent70ede44dcc23137f8f48af5527c183dc1f9276a7 (diff)
Do not crash when starting up with a bad config file. Check that
conf.listen_addr is actually valid before deref.
Diffstat (limited to 'usr.sbin/bgpd/bgpd.c')
-rw-r--r--usr.sbin/bgpd/bgpd.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c
index 3d02f5a9210..59ace434811 100644
--- a/usr.sbin/bgpd/bgpd.c
+++ b/usr.sbin/bgpd/bgpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.c,v 1.152 2009/12/31 15:34:02 claudio Exp $ */
+/* $OpenBSD: bgpd.c,v 1.153 2010/01/11 05:47:51 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -365,11 +365,12 @@ main(int argc, char *argv[])
LIST_REMOVE(m, entry);
free(m);
}
- while ((la = TAILQ_FIRST(conf.listen_addrs)) != NULL) {
- TAILQ_REMOVE(conf.listen_addrs, la, entry);
- close(la->fd);
- free(la);
- }
+ if (conf.listen_addrs)
+ while ((la = TAILQ_FIRST(conf.listen_addrs)) != NULL) {
+ TAILQ_REMOVE(conf.listen_addrs, la, entry);
+ close(la->fd);
+ free(la);
+ }
free(rules_l);
control_cleanup(conf.csock);