Skip to contentSkip to conversation

scanner: fix search_in_include_path test

PATCH Applied Anatole Denis 2 participants 2 messages Jan 2, 2017 – Jan 3, 2017 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scanner: fix search_in_include_path test

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 f92a1a5c4a8761c39a76b264859f0ff2c8f71179
---
 src/scanner.l | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/scanner.l +2 -2
index 625023f..bf88955 100644
@@ -629,8 +629,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] != '/');
 }
 
Signature · 1 line
2.11.0
maintainer Applied
#1 lore raw
Quoted 4 lines · Anatole Denis

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.

Applied, thanks Anatole.