summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorErik Flodin <erik@flodin.me>2022-11-27 21:32:36 +0100
committerGitHub <noreply@github.com>2022-11-27 21:32:36 +0100
commite104ef081ef235e18ae8d6ce6e98b9a0a59633b9 (patch)
tree784057f6ab03bd1660f4a3113b7e108b79823b7f /src
parent1527040bc2a278b9d3d51badb732ecf5841d8bb5 (diff)
downloadccache-e104ef081ef235e18ae8d6ce6e98b9a0a59633b9.tar.gz
fix: Fix edge case where a non-temporal identifier is misidentified (#1227)
If a non-temporal identifier, that ends with a temporal macro, happens to be at the end of the buffer with the temporal suffix starting on the avx boundary, then it would be incorrectly classified as a temporal macro. This since the helper function lacks the context to see that the data before the match is something that invalidates the match.
Diffstat (limited to 'src')
-rw-r--r--src/hashutil.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/hashutil.cpp b/src/hashutil.cpp
index 8d7151d6..796eb3a2 100644
--- a/src/hashutil.cpp
+++ b/src/hashutil.cpp
@@ -93,14 +93,14 @@ check_for_temporal_macros_helper(std::string_view str, size_t pos)
}
int
-check_for_temporal_macros_bmh(std::string_view str)
+check_for_temporal_macros_bmh(std::string_view str, size_t start = 0)
{
int result = 0;
// We're using the Boyer-Moore-Horspool algorithm, which searches starting
// from the *end* of the needle. Our needles are 8 characters long, so i
// starts at 7.
- size_t i = 7;
+ size_t i = start + 7;
while (i < str.length()) {
// Check whether the substring ending at str[i] has the form "_....E..". On
@@ -173,7 +173,7 @@ check_for_temporal_macros_avx2(std::string_view str)
}
}
- result |= check_for_temporal_macros_bmh(str.substr(pos));
+ result |= check_for_temporal_macros_bmh(str, pos);
return result;
}