aboutsummaryrefslogtreecommitdiff
path: root/instrumentation/compare-transform-pass.so.cc
diff options
context:
space:
mode:
authorvanhauser-thc <vh@thc.org>2021-03-02 16:24:43 +0100
committervanhauser-thc <vh@thc.org>2021-03-02 16:24:43 +0100
commit333509bb0a56be9bd2e236f0e2f37d4af2dd7d59 (patch)
tree011f0afcfa23a1fc88b587a7a5be6c3981dd02dd /instrumentation/compare-transform-pass.so.cc
parentc269c3977ccb96710a2488b19c72bae51832a827 (diff)
downloadafl++-333509bb0a56be9bd2e236f0e2f37d4af2dd7d59.tar.gz
better unicode support
Diffstat (limited to 'instrumentation/compare-transform-pass.so.cc')
-rw-r--r--instrumentation/compare-transform-pass.so.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/instrumentation/compare-transform-pass.so.cc b/instrumentation/compare-transform-pass.so.cc
index 84301493..a85522a2 100644
--- a/instrumentation/compare-transform-pass.so.cc
+++ b/instrumentation/compare-transform-pass.so.cc
@@ -421,14 +421,21 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
}
// add null termination character implicit in c strings
- TmpConstStr.append("\0", 1);
+ if (TmpConstStr[TmpConstStr.length() - 1] != 0) {
+
+ TmpConstStr.append("\0", 1);
+
+ }
// in the unusual case the const str has embedded null
// characters, the string comparison functions should terminate
// at the first null
- if (!isMemcmp)
+ if (!isMemcmp) {
+
TmpConstStr.assign(TmpConstStr, 0, TmpConstStr.find('\0') + 1);
+ }
+
constStrLen = TmpConstStr.length();
// prefer use of StringRef (in comparison to std::string a StringRef has
// built-in runtime bounds checking, which makes debugging easier)