diff options
| author | van Hauser <vh@thc.org> | 2021-10-09 18:50:35 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-09 18:50:35 +0200 |
| commit | 7b1fed78d88cce2ad6134597bda37e2125cdabc7 (patch) | |
| tree | 0bb65b95ccb4a9e5dec40b1ffd6774b20a6fe26b /instrumentation/afl-llvm-lto-instrumentation.so.cc | |
| parent | 0a88a6c53071e9c203fa602e99e6510de14dacc0 (diff) | |
| parent | 580401591f36b0f6f7ba3ee08c867e12415e5cc5 (diff) | |
| download | afl++-7b1fed78d88cce2ad6134597bda37e2125cdabc7.tar.gz | |
Merge pull request #1107 from devnexen/llvm_pass_update
LLVM passes making slightly more C++
Diffstat (limited to 'instrumentation/afl-llvm-lto-instrumentation.so.cc')
| -rw-r--r-- | instrumentation/afl-llvm-lto-instrumentation.so.cc | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/instrumentation/afl-llvm-lto-instrumentation.so.cc b/instrumentation/afl-llvm-lto-instrumentation.so.cc index 4a5738de..73e41f60 100644 --- a/instrumentation/afl-llvm-lto-instrumentation.so.cc +++ b/instrumentation/afl-llvm-lto-instrumentation.so.cc @@ -108,8 +108,8 @@ bool AFLLTOPass::runOnModule(Module &M) { // std::vector<CallInst *> calls; DenseMap<Value *, std::string *> valueMap; std::vector<BasicBlock *> BlockList; + std::ofstream dFile; char * ptr; - FILE * documentFile = NULL; size_t found = 0; srand((unsigned int)time(NULL)); @@ -137,7 +137,8 @@ bool AFLLTOPass::runOnModule(Module &M) { if ((ptr = getenv("AFL_LLVM_DOCUMENT_IDS")) != NULL) { - if ((documentFile = fopen(ptr, "a")) == NULL) + dFile.open(ptr, std::ofstream::out | std::ofstream::app); + if (!dFile.is_open()) WARNF("Cannot access document file %s", ptr); } @@ -845,10 +846,9 @@ bool AFLLTOPass::runOnModule(Module &M) { } - if (documentFile) { + if (dFile.is_open()) { - fprintf(documentFile, "ModuleID=%llu Function=%s edgeID=%u\n", - moduleID, F.getName().str().c_str(), afl_global_id); + dFile << "ModuleID=" << moduleID << " Function=" << F.getName().str() << " edgeID=" << afl_global_id << "\n"; } @@ -920,8 +920,7 @@ bool AFLLTOPass::runOnModule(Module &M) { } - if (documentFile) fclose(documentFile); - documentFile = NULL; + if (dFile.is_open()) dFile.close(); // save highest location ID to global variable // do this after each function to fail faster |
