]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
scanner: fix search_in_include_path test
authorAnatole Denis <anatole@rezel.net>
Mon, 2 Jan 2017 15:30:01 +0000 (16:30 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 3 Jan 2017 13:21:53 +0000 (14:21 +0100)
clang emits a warning in this function as we're using a boolean as the third
argument to strncmp. Indeed, this function only checks the first byte of the
path as is, so files beginning with . will be incorrectly included from the
current working directory instead of the include directory.

Fixes: f92a1a5c4a87 ("scanner: honor absolute and relative paths via include file")
Signed-off-by: Anatole Denis <anatole@rezel.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/scanner.l

index 69406bd0164e0f6ec9ea4de6a5be4c17fd5888fc..6b441b543efe2ae2af9477c0354c1e69ed37a7e5 100644 (file)
@@ -635,8 +635,8 @@ err:
 
 static bool search_in_include_path(const char *filename)
 {
-       return (strncmp(filename, "./", strlen("./") != 0) &&
-               strncmp(filename, "../", strlen("../") != 0) &&
+       return (strncmp(filename, "./", strlen("./")) != 0 &&
+               strncmp(filename, "../", strlen("../")) != 0 &&
                filename[0] != '/');
 }