From bc9ddf987d3c454e1cdca29f44508914a0f5f5d5 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 1 Aug 2016 23:26:22 +0200 Subject: 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 --- src/scanner.l | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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) -- cgit v1.2.3