better unicode support
MODIFY
docs/Changelog.md
docs/Changelog.md
@@ -10,7 +10,8 @@ sending a mail to <afl-users+subscribe@googlegroups.com>.
### Version ++3.11a (dev)
- afl-cc
- - fixed for a crash that can occur with ASAN + CMPLOG together
+ - fixed for a crash that can occur with ASAN + CMPLOG together plus
+ better support for unicode (thanks to @stbergmann for reporting!)
### Version ++3.10c (release)
- Mac OS ARM64 support

MODIFY
instrumentation/SanitizerCoverageLTO.so.cc
instrumentation/SanitizerCoverageLTO.so.cc
@@ -872,13 +872,15 @@ bool ModuleSanitizerCoverage::instrumentModule(
// was not already added
if (!isMemcmp) {
- if (addedNull == false) {
+ if (addedNull == false && thestring[optLen - 1] != '\0') {
thestring.append("\0", 1); // add null byte
optLen++;
}
+ if (!isStdString) {
+
// ensure we do not have garbage
size_t offset = thestring.find('\0', 0);
if (offset + 1 < optLen) optLen = offset + 1;
@@ -886,6 +888,8 @@ bool ModuleSanitizerCoverage::instrumentModule(
}
+ }
+
if (!be_quiet) {
std::string outstring;

MODIFY
instrumentation/afl-llvm-dict2file.so.cc
instrumentation/afl-llvm-dict2file.so.cc
@@ -543,13 +543,15 @@ bool AFLdict2filePass::runOnModule(Module &M) {
// was not already added
if (!isMemcmp) {
- if (addedNull == false) {
+ if (addedNull == false && thestring[optLen - 1] != '\0') {
thestring.append("\0", 1); // add null byte
optLen++;
}
+ if (!isStdString) {
+
// ensure we do not have garbage
size_t offset = thestring.find('\0', 0);
if (offset + 1 < optLen) optLen = offset + 1;
@@ -557,6 +559,8 @@ bool AFLdict2filePass::runOnModule(Module &M) {
}
+ }
+
// we take the longer string, even if the compare was to a
// shorter part. Note that depending on the optimizer of the
// compiler this can be wrong, but it is more likely that this

MODIFY
instrumentation/afl-llvm-lto-instrumentation.so.cc
instrumentation/afl-llvm-lto-instrumentation.so.cc
@@ -658,13 +658,15 @@ bool AFLLTOPass::runOnModule(Module &M) {
// was not already added
if (!isMemcmp) {
- if (addedNull == false) {
+ if (addedNull == false && thestring[optLen - 1] != '\0') {
thestring.append("\0", 1); // add null byte
optLen++;
}
+ if (!isStdString) {
+
// ensure we do not have garbage
size_t offset = thestring.find('\0', 0);
if (offset + 1 < optLen) optLen = offset + 1;
@@ -672,6 +674,8 @@ bool AFLLTOPass::runOnModule(Module &M) {
}
+ }
+
if (!be_quiet) {
fprintf(stderr, "%s: length %zu/%zu \"", FuncName.c_str(), optLen,

MODIFY
instrumentation/compare-transform-pass.so.cc
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
+ 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)

better unicode support