From: Mark Andrews Date: Fri, 27 Apr 2012 11:24:43 +0000 (+1000) Subject: 3197. [bug] Don't try to log the filename and line number when X-Git-Tag: v9.6-ESV-R7~21 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=67546361cb8d72fa61832f30676bb4a35ee71c7f;p=thirdparty%2Fbind9.git 3197. [bug] Don't try to log the filename and line number when the config parser can't open a file. [RT #22263] --- diff --git a/CHANGES b/CHANGES index ac33e56f427..cbb67ac18d7 100644 --- a/CHANGES +++ b/CHANGES @@ -29,6 +29,9 @@ 3232. [bug] Zero zone->curmaster before return in dns_zone_setmasterswithkeys(). [RT #26732] +3197. [bug] Don't try to log the filename and line number when + the config parser can't open a file. [RT #22263] + --- 9.6-ESV-R6 released --- 3298. [bug] Named could dereference a NULL pointer in diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index 8bb563a1b74..3d02379447e 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -2203,16 +2203,30 @@ cfg_parser_warning(cfg_parser_t *pctx, unsigned int flags, const char *fmt, ...) #define MAX_LOG_TOKEN 30 /* How much of a token to quote in log messages. */ +static isc_boolean_t +have_current_file(cfg_parser_t *pctx) { + cfg_listelt_t *elt; + if (pctx->open_files == NULL) + return (ISC_FALSE); + + elt = ISC_LIST_TAIL(pctx->open_files->value.list); + if (elt == NULL) + return (ISC_FALSE); + + return (ISC_TRUE); +} + static char * current_file(cfg_parser_t *pctx) { static char none[] = "none"; cfg_listelt_t *elt; cfg_obj_t *fileobj; - if (pctx->open_files == NULL) + if (!have_current_file(pctx)) return (none); + elt = ISC_LIST_TAIL(pctx->open_files->value.list); - if (elt == NULL) + if (elt == NULL) /* shouldn't be possible, but... */ return (none); fileobj = elt->obj; @@ -2235,8 +2249,10 @@ parser_complain(cfg_parser_t *pctx, isc_boolean_t is_warning, if (is_warning) level = ISC_LOG_WARNING; - snprintf(where, sizeof(where), "%s:%u: ", - current_file(pctx), pctx->line); + where[0] = '\0'; + if (have_current_file(pctx)) + snprintf(where, sizeof(where), "%s:%u: ", + current_file(pctx), pctx->line); len = vsnprintf(message, sizeof(message), format, args); if (len >= sizeof(message))