do not add zero byte on string compares with len
MODIFY
instrumentation/SanitizerCoverageLTO.so.cc
instrumentation/SanitizerCoverageLTO.so.cc
@@ -922,13 +922,16 @@ bool ModuleSanitizerCoverage::instrumentModule(
// was not already added
if (!isMemcmp) {
- if (addedNull == false && thestring[optLen - 1] != '\0') {
+ /*
+ if (addedNull == false && thestring[optLen - 1] !=
+ '\0') {
thestring.append("\0", 1); // add null byte
optLen++;
}
+ */
if (!isStdString) {
// ensure we do not have garbage

MODIFY
instrumentation/afl-llvm-dict2file.so.cc
instrumentation/afl-llvm-dict2file.so.cc
@@ -603,18 +603,27 @@ bool AFLdict2filePass::runOnModule(Module &M) {
// was not already added
if (!isMemcmp) {
- if (addedNull == false && thestring[optLen - 1] != '\0') {
+ /*
+ 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;
+ if (offset && offset < opLen && offset + 1 < optLen) {
+
+ optLen = offset + 1;
+
+ }
+
thestring = thestring.substr(0, optLen);
}

MODIFY
instrumentation/compare-transform-pass.so.cc
instrumentation/compare-transform-pass.so.cc
@@ -442,6 +442,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
bool isSizedcmp = false;
bool isCaseInsensitive = false;
Function * Callee = callInst->getCalledFunction();
+
if (Callee) {
isMemcmp = Callee->getName().compare("memcmp") == 0;

do not add zero byte on string compares with len