aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Carlier <devnexen@gmail.com>2021-10-09 18:31:12 +0100
committerDavid Carlier <devnexen@gmail.com>2021-10-09 18:31:12 +0100
commit65afe5addc7d5bd741a5283eeba4813849e99836 (patch)
treeeb5c07eb63ccef94f0efdb855525185abbbd9f6d
parent7b1fed78d88cce2ad6134597bda37e2125cdabc7 (diff)
downloadafl++-65afe5addc7d5bd741a5283eeba4813849e99836.tar.gz
LLVM coverage making it more C++ too.
-rw-r--r--instrumentation/SanitizerCoverageLTO.so.cc17
1 files changed, 5 insertions, 12 deletions
diff --git a/instrumentation/SanitizerCoverageLTO.so.cc b/instrumentation/SanitizerCoverageLTO.so.cc
index eb0f06b2..960eb783 100644
--- a/instrumentation/SanitizerCoverageLTO.so.cc
+++ b/instrumentation/SanitizerCoverageLTO.so.cc
@@ -1065,7 +1065,6 @@ bool ModuleSanitizerCoverage::instrumentModule(
if (dictionary.size()) {
size_t memlen = 0, count = 0, offset = 0;
- char * ptr;
// sort and unique the dictionary
std::sort(dictionary.begin(), dictionary.end());
@@ -1085,13 +1084,7 @@ bool ModuleSanitizerCoverage::instrumentModule(
if (count) {
- if ((ptr = (char *)malloc(memlen + count)) == NULL) {
-
- fprintf(stderr, "Error: malloc for %lu bytes failed!\n",
- memlen + count);
- exit(-1);
-
- }
+ auto ptrhld = std::unique_ptr<char []>(new char[memlen + count]);
count = 0;
@@ -1099,8 +1092,8 @@ bool ModuleSanitizerCoverage::instrumentModule(
if (offset + token.length() < 0xfffff0 && count < MAX_AUTO_EXTRAS) {
- ptr[offset++] = (uint8_t)token.length();
- memcpy(ptr + offset, token.c_str(), token.length());
+ ptrhld.get()[offset++] = (uint8_t)token.length();
+ memcpy(ptrhld.get() + offset, token.c_str(), token.length());
offset += token.length();
count++;
@@ -1120,10 +1113,10 @@ bool ModuleSanitizerCoverage::instrumentModule(
GlobalVariable *AFLInternalDictionary = new GlobalVariable(
M, ArrayTy, true, GlobalValue::ExternalLinkage,
ConstantDataArray::get(Ctx,
- *(new ArrayRef<char>((char *)ptr, offset))),
+ *(new ArrayRef<char>(ptrhld.get(), offset))),
"__afl_internal_dictionary");
AFLInternalDictionary->setInitializer(ConstantDataArray::get(
- Ctx, *(new ArrayRef<char>((char *)ptr, offset))));
+ Ctx, *(new ArrayRef<char>(ptrhld.get(), offset))));
AFLInternalDictionary->setConstant(true);
GlobalVariable *AFLDictionary = new GlobalVariable(