about summary refs log tree commit diff
path: root/instrumentation/afl-llvm-pass.so.cc
diff options
context:
space:
mode:
authorcarpintero-de-c <175505615+carpintero-de-c@users.noreply.github.com>2024-07-14 03:55:58 +0530
committerGitHub <noreply@github.com>2024-07-14 00:25:58 +0200
commit7c380a6612f00e4a7ed02364dc2b3769e8edc8f8 (patch)
treefd78a050b4fa1372f6d023f10f3513a76e1ee769 /instrumentation/afl-llvm-pass.so.cc
parent3f26818d973c4929857977b7cdfcf26cc0a84eb3 (diff)
downloadafl++-7c380a6612f00e4a7ed02364dc2b3769e8edc8f8.tar.gz
Replace gettimeofday with clock_gettime (#2159)
Diffstat (limited to 'instrumentation/afl-llvm-pass.so.cc')
-rw-r--r--instrumentation/afl-llvm-pass.so.cc9
1 files changed, 4 insertions, 5 deletions
diff --git a/instrumentation/afl-llvm-pass.so.cc b/instrumentation/afl-llvm-pass.so.cc
index 75b8532b..fb5b856c 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,14 +211,13 @@ bool AFLCoverage::runOnModule(Module &M) {
   IntegerType *IntLocTy =
       IntegerType::getIntNTy(C, sizeof(PREV_LOC_T) * CHAR_BIT);
 #endif
-  struct timeval  tv;
-  struct timezone tz;
+  struct timespec spec;
   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();
+  clock_gettime(CLOCK_REALTIME, &spec);
+  rand_seed = spec.tv_sec ^ spec.tv_nsec ^ getpid();
   AFL_SR(rand_seed);
 
   /* Show a banner */