From: Pablo Neira Ayuso Date: Mon, 1 Aug 2016 21:26:22 +0000 (+0200) Subject: scanner: don't fall back on current directory if include is not found X-Git-Tag: v0.7~127 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bc9ddf987d3c454e1cdca29f44508914a0f5f5d5;p=thirdparty%2Fnftables.git scanner: don't fall back on current directory if include is not found This resolves an ambiguity if the same file name is used both under sysconfdir and the current working directory. You can use dot slash ./ to explicitly refer to files in the current working directory. Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1040 Signed-off-by: Pablo Neira Ayuso --- diff --git a/src/scanner.l b/src/scanner.l index 6f1a5512..cb2ea320 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -639,16 +639,15 @@ int scanner_include_file(void *scanner, const char *filename, if (f != NULL) break; } - } - if (f == NULL) { + } else { f = fopen(filename, "r"); - if (f == NULL) { - erec = error(loc, "Could not open file \"%s\": %s\n", - filename, strerror(errno)); - goto err; - } name = filename; } + if (f == NULL) { + erec = error(loc, "Could not open file \"%s\": %s\n", + filename, strerror(errno)); + goto err; + } erec = scanner_push_file(scanner, name, f, loc); if (erec != NULL)