summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/util.cc4
-rw-r--r--src/util_test.cc4
2 files changed, 7 insertions, 1 deletions
diff --git a/src/util.cc b/src/util.cc
index 4df81dd..7717ef4 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -145,8 +145,10 @@ bool CanonicalizePath(char* path, size_t* len, unsigned int* slash_bits,
bits_offset++;
}
}
- if (bits_offset > 32)
+ if (bits_offset > 32) {
+ *err = "too many path components";
return false;
+ }
bits_offset = 0;
#endif
diff --git a/src/util_test.cc b/src/util_test.cc
index 5bbf397..13730af 100644
--- a/src/util_test.cc
+++ b/src/util_test.cc
@@ -272,15 +272,19 @@ TEST(CanonicalizePath, TooManyComponents) {
EXPECT_EQ(slash_bits, 0xffff);
// 33 is not.
+ err = "";
path =
"a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/x.h";
EXPECT_FALSE(CanonicalizePath(&path, &slash_bits, &err));
+ EXPECT_EQ(err, "too many path components");
// Backslashes version.
+ err = "";
path =
"a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\."
"\\a\\.\\a\\.\\a\\.\\a\\.\\a\\x.h";
EXPECT_FALSE(CanonicalizePath(&path, &slash_bits, &err));
+ EXPECT_EQ(err, "too many path components");
}
#endif