about summary refs log tree commit diff
path: root/llvm_mode/afl-llvm-pass.so.cc
diff options
context:
space:
mode:
authorAndrea Fioraldi <andreafioraldi@gmail.com>2019-11-11 14:36:06 +0100
committerGitHub <noreply@github.com>2019-11-11 14:36:06 +0100
commit659db7e421b47da4b04110a141d9c20307f74ecc (patch)
tree18f9c38cc5270adcf445a62b974712cead4a01c4 /llvm_mode/afl-llvm-pass.so.cc
parentcd84339bccc104a51a5da614a9f82cc4ae615cce (diff)
parent01d55372441960c435af8f3bd6b61d1302042728 (diff)
downloadafl++-659db7e421b47da4b04110a141d9c20307f74ecc.tar.gz
Merge branch 'master' into radamsa
Diffstat (limited to 'llvm_mode/afl-llvm-pass.so.cc')
-rw-r--r--llvm_mode/afl-llvm-pass.so.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm_mode/afl-llvm-pass.so.cc b/llvm_mode/afl-llvm-pass.so.cc
index 3ca5ccc4..0c68136b 100644
--- a/llvm_mode/afl-llvm-pass.so.cc
+++ b/llvm_mode/afl-llvm-pass.so.cc
@@ -3,7 +3,7 @@
    ---------------------------------------------------
 
    Written by Laszlo Szekeres <lszekeres@google.com> and
-              Michal Zalewski <lcamtuf@google.com>
+              Michal Zalewski
 
    LLVM integration design comes from Laszlo Szekeres. C bits copied-and-pasted
    from afl-as.c are Michal's fault.
@@ -34,6 +34,7 @@
 #include <list>
 #include <string>
 #include <fstream>
+#include <sys/time.h>
 
 #include "llvm/IR/DebugInfo.h"
 #include "llvm/IR/BasicBlock.h"
@@ -95,8 +96,16 @@ bool AFLCoverage::runOnModule(Module &M) {
 
   IntegerType *Int8Ty = IntegerType::getInt8Ty(C);
   IntegerType *Int32Ty = IntegerType::getInt32Ty(C);
+  struct timeval            tv;
+  struct timezone           tz;
+  u32                       rand_seed;
   unsigned int cur_loc = 0;
 
+  /* Setup random() so we get Actually Random(TM) outputs from AFL_R() */
+  gettimeofday(&tv, &tz);
+  rand_seed = tv.tv_sec ^ tv.tv_usec ^ getpid();
+  AFL_SR(rand_seed);
+
   /* Show a banner */
 
   char be_quiet = 0;
@@ -181,6 +190,8 @@ bool AFLCoverage::runOnModule(Module &M) {
 
           }
 
+          (void)instLine;
+
           /* Continue only if we know where we actually are */
           if (!instFilename.str().empty()) {