From b46f88af58a8d288797f9ac76d7aef32576d1360 Mon Sep 17 00:00:00 2001 From: Marco Pfatschbacher Date: Tue, 26 Feb 2008 10:09:59 +0000 Subject: 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@ --- usr.sbin/bgpd/parse.y | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'usr.sbin/bgpd/parse.y') diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y index a7f912e07f4..2c8c60e1604 100644 --- a/usr.sbin/bgpd/parse.y +++ b/usr.sbin/bgpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.214 2007/11/12 23:59:41 mpf Exp $ */ +/* $OpenBSD: parse.y,v 1.215 2008/02/26 10:09:58 mpf Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer @@ -47,7 +47,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 *); @@ -1884,8 +1884,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); } @@ -1903,7 +1904,7 @@ lgetc(int quotec) } while (c == EOF) { - if (popfile() == EOF) + if (file == topfile || popfile() == EOF) return (EOF); c = getc(file->stream); } @@ -2145,16 +2146,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 @@ -2177,6 +2177,7 @@ parse_config(char *filename, struct bgpd_config *xconf, free(conf); return (-1); } + topfile = file; if ((mrtconf = calloc(1, sizeof(struct mrt_head))) == NULL) fatal(NULL); -- cgit v1.2.3