summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhenning <henning@openbsd.org>2004-11-04 14:05:46 +0000
committerhenning <henning@openbsd.org>2004-11-04 14:05:46 +0000
commitf621dbad74ba0d18b59108cda672529840d52416 (patch)
tree9fad6189cb34c2005b1b6391f3920de7ba8d7cd7
parentfix url (submitter by maintainer of site) (diff)
downloadwireguard-openbsd-f621dbad74ba0d18b59108cda672529840d52416.tar.xz
wireguard-openbsd-f621dbad74ba0d18b59108cda672529840d52416.zip
(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!
-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);