diff options
author | Marco Pfatschbacher <mpf@cvs.openbsd.org> | 2008-02-26 10:09:59 +0000 |
---|---|---|
committer | Marco Pfatschbacher <mpf@cvs.openbsd.org> | 2008-02-26 10:09:59 +0000 |
commit | b46f88af58a8d288797f9ac76d7aef32576d1360 (patch) | |
tree | 5b31427ce019869d392e57042555456ed9749fda /usr.sbin/hostapd/parse.y | |
parent | c5ad3516ac1e4caaf6eafee610f3a026efecc199 (diff) |
Have popfile() also close the main config file,
but only do the final popfile call after yyparse() is done.
This also fixes config reload on SIGHUP for some daemons.
Spotted by otto@. OK deraadt@
Diffstat (limited to 'usr.sbin/hostapd/parse.y')
-rw-r--r-- | usr.sbin/hostapd/parse.y | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/usr.sbin/hostapd/parse.y b/usr.sbin/hostapd/parse.y index 4f4103cd656..820917e4b3b 100644 --- a/usr.sbin/hostapd/parse.y +++ b/usr.sbin/hostapd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.36 2007/11/12 23:59:41 mpf Exp $ */ +/* $OpenBSD: parse.y,v 1.37 2008/02/26 10:09:58 mpf Exp $ */ /* * Copyright (c) 2004, 2005, 2006 Reyk Floeter <reyk@openbsd.org> @@ -64,7 +64,7 @@ static struct file { char *name; int lineno; int errors; -} *file; +} *file, *topfile; struct file *pushfile(const char *, int); int popfile(void); int check_file_secrecy(int, const char *); @@ -1351,8 +1351,9 @@ lgetc(int quotec) if (quotec) { if ((c = getc(file->stream)) == EOF) { - yyerror("reached end of file while parsing quoted string"); - if (popfile() == EOF) + yyerror("reached end of file while parsing " + "quoted string"); + if (file == topfile || popfile() == EOF) return (EOF); return (quotec); } @@ -1370,7 +1371,7 @@ lgetc(int quotec) } while (c == EOF) { - if (popfile() == EOF) + if (file == topfile || popfile() == EOF) return (EOF); c = getc(file->stream); } @@ -1689,16 +1690,15 @@ popfile(void) { struct file *prev; - if ((prev = TAILQ_PREV(file, files, entry)) != NULL) { + if ((prev = TAILQ_PREV(file, files, entry)) != NULL) prev->errors += file->errors; - TAILQ_REMOVE(&files, file, entry); - fclose(file->stream); - free(file->name); - free(file); - file = prev; - return (0); - } - return (EOF); + + TAILQ_REMOVE(&files, file, entry); + fclose(file->stream); + free(file->name); + free(file); + file = prev; + return (file ? 0 : EOF); } int @@ -1739,6 +1739,7 @@ hostapd_parse_file(struct hostapd_config *cfg) free(sym); } } + topfile = file; return (errors ? EINVAL : ret); } |