about summary refs log tree commit diff
path: root/instrumentation/afl-llvm-pass.so.cc
diff options
context:
space:
mode:
authorvanhauser-thc <vh@thc.org>2024-07-14 10:18:23 +0200
committervanhauser-thc <vh@thc.org>2024-07-14 10:18:23 +0200
commitccb952dde8dbf2165a0d84308e558cd68679fb13 (patch)
treeaa6f0c11c8fe554cc3facb3c1a76ac9ec9822594 /instrumentation/afl-llvm-pass.so.cc
parent7c380a6612f00e4a7ed02364dc2b3769e8edc8f8 (diff)
downloadafl++-ccb952dde8dbf2165a0d84308e558cd68679fb13.tar.gz
Revert "Replace gettimeofday with clock_gettime (#2159)"
This reverts commit 7c380a6612f00e4a7ed02364dc2b3769e8edc8f8.
Diffstat (limited to 'instrumentation/afl-llvm-pass.so.cc')
-rw-r--r--instrumentation/afl-llvm-pass.so.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/instrumentation/afl-llvm-pass.so.cc b/instrumentation/afl-llvm-pass.so.cc
index fb5b856c..75b8532b 100644
--- a/instrumentation/afl-llvm-pass.so.cc
+++ b/instrumentation/afl-llvm-pass.so.cc
@@ -32,12 +32,12 @@
 #include "debug.h"
 #include <stdio.h>
 #include <stdlib.h>
-#include <time.h>
 #include <unistd.h>
 
 #include <list>
 #include <string>
 #include <fstream>
+#include <sys/time.h>
 
 #include "llvm/Config/llvm-config.h"
 #if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 5
@@ -211,13 +211,14 @@ bool AFLCoverage::runOnModule(Module &M) {
   IntegerType *IntLocTy =
       IntegerType::getIntNTy(C, sizeof(PREV_LOC_T) * CHAR_BIT);
 #endif
-  struct timespec spec;
+  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() */
-  clock_gettime(CLOCK_REALTIME, &spec);
-  rand_seed = spec.tv_sec ^ spec.tv_nsec ^ getpid();
+  gettimeofday(&tv, &tz);
+  rand_seed = tv.tv_sec ^ tv.tv_usec ^ getpid();
   AFL_SR(rand_seed);
 
   /* Show a banner */