about summary refs log tree commit diff
path: root/llvm_mode/afl-llvm-pass.so.cc
diff options
context:
space:
mode:
Diffstat (limited to 'llvm_mode/afl-llvm-pass.so.cc')
-rw-r--r--llvm_mode/afl-llvm-pass.so.cc43
1 files changed, 18 insertions, 25 deletions
diff --git a/llvm_mode/afl-llvm-pass.so.cc b/llvm_mode/afl-llvm-pass.so.cc
index 7d5cb224..77d63ce4 100644
--- a/llvm_mode/afl-llvm-pass.so.cc
+++ b/llvm_mode/afl-llvm-pass.so.cc
@@ -468,31 +468,24 @@ bool AFLCoverage::runOnModule(Module &M) {
     if (!inst_blocks)
       WARNF("No instrumentation targets found.");
     else {
-      char mode[64];
-      int not_hardened = 1;
-      if (getenv("AFL_HARDEN")) {
-        strcat(mode, "/hardened");
-        not_hardened = 0;
-      }      
-      if (getenv("AFL_USE_ASAN")) {
-        strcat(mode, "/ASAN");
-        not_hardened = 0;
-      }
-      if (getenv("AFL_USE_MSAN")) {
-        strcat(mode, "/MSAN");
-        not_hardened = 0;
-      }
-      if (getenv("AFL_USE_UBSAN")) {
-        strcat(mode, "/UNSAN");
-        not_hardened = 0;
-      }
-      
-      if (not_hardened)
-        OKF("Instrumented %u locations (non-hardened mode, ratio %u%%).",
-            inst_blocks, inst_ratio);
-      else
-        OKF("Instrumented %u locations (%s mode, ratio %u%%).", inst_blocks,
-            &mode[1], inst_ratio);
+      char modeline[100];
+      snprintf(modeline, sizeof(modeline), "%s%s%s%s", 
+          getenv("AFL_HARDEN")
+              ? "hardened"
+              : "non-hardened",
+          getenv("AFL_USE_ASAN")
+              ? ", ASAN"
+              : "",
+          getenv("AFL_USE_MSAN")
+              ? ", MSAN"
+              : "",
+          getenv("AFL_USE_UBSAN")
+              ? ", UBSAN"
+              : ""
+         );
+      OKF("Instrumented %u locations (%s mode, ratio %u%%).", inst_blocks,
+          modeline,
+          inst_ratio);
     }
 
   }