]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
scanner: don't fall back on current directory if include is not found
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 1 Aug 2016 21:26:22 +0000 (23:26 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 10 Aug 2016 08:27:11 +0000 (10:27 +0200)
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 <pablo@netfilter.org>
src/scanner.l

index 6f1a5512a81e04f3b6873af7695750e2b9f7a0e2..cb2ea3201bf0150c90fcf0e28f4a640485901ac5 100644 (file)
@@ -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)