summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-11-04 14:05:47 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-11-04 14:05:47 +0000
commita070d556e386fcf8be52e10d004578b16e3cf936 (patch)
tree04ae5b6fb723f189dd9b154e17c3a809d58a818b /usr.sbin
parentad8cf60c0420161041975b5cbfc5ab758c5997f6 (diff)
(try to) open the config file earlier, makes the error handling easier in
case we cannot. in fact there was one missing free(), thus this diff plugs a little memory hole (without real-world relevance I guess). From Patrick Latifi, thanks!
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/parse.y28
1 files changed, 12 insertions, 16 deletions
diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y
index 6634244a094..b8453aff4d5 100644
--- a/usr.sbin/bgpd/parse.y
+++ b/usr.sbin/bgpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.141 2004/10/19 12:02:50 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.142 2004/11/04 14:05:46 henning Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -1486,6 +1486,17 @@ parse_config(char *filename, struct bgpd_config *xconf,
struct sym *sym, *next;
struct peer *p, *pnext;
+ if ((fin = fopen(filename, "r")) == NULL) {
+ warn("%s", filename);
+ return (-1);
+ }
+ infile = filename;
+
+ if (check_file_secrecy(fileno(fin), filename)) {
+ fclose(fin);
+ return (-1);
+ }
+
if ((conf = calloc(1, sizeof(struct bgpd_config))) == NULL)
fatal(NULL);
if ((mrtconf = calloc(1, sizeof(struct mrt_head))) == NULL)
@@ -1508,21 +1519,6 @@ parse_config(char *filename, struct bgpd_config *xconf,
TAILQ_INIT(filter_l);
conf->opts = xconf->opts;
- if ((fin = fopen(filename, "r")) == NULL) {
- warn("%s", filename);
- free(conf);
- free(mrtconf);
- return (-1);
- }
- infile = filename;
-
- if (check_file_secrecy(fileno(fin), filename)) {
- fclose(fin);
- free(conf);
- free(mrtconf);
- return (-1);
- }
-
yyparse();
fclose(fin);