]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3197. [bug] Don't try to log the filename and line number when
authorMark Andrews <marka@isc.org>
Fri, 27 Apr 2012 05:08:01 +0000 (15:08 +1000)
committerMark Andrews <marka@isc.org>
Fri, 27 Apr 2012 05:08:01 +0000 (15:08 +1000)
                        the config parser can't open a file. [RT #22263]

CHANGES
lib/isccfg/parser.c

diff --git a/CHANGES b/CHANGES
index a16d4a1c7063de0977ba93eec25c48b0aaa5711a..dcec31d062e370d9511071e07f5013a20b8b425b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -42,6 +42,9 @@
 
 3183.  [bug]           Added RTLD_GLOBAL flag to dlopen call. [RT #26301]
 
+3197.  [bug]           Don't try to log the filename and line number when
+                       the config parser can't open a file. [RT #22263]
+
        --- 9.8.2 released ---
 
 3298.  [bug]           Named could dereference a NULL pointer in
index 1d1f08e0d2c09682533c0afecbc2819715e462cc..ef20184f397550c384de771e0f402e5002ee4a36 100644 (file)
@@ -2232,16 +2232,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;
@@ -2264,8 +2278,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))