aboutsummaryrefslogtreecommitdiff
path: root/src
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 /src
parent7c380a6612f00e4a7ed02364dc2b3769e8edc8f8 (diff)
downloadafl++-ccb952dde8dbf2165a0d84308e558cd68679fb13.tar.gz
Revert "Replace gettimeofday with clock_gettime (#2159)"
This reverts commit 7c380a6612f00e4a7ed02364dc2b3769e8edc8f8.
Diffstat (limited to 'src')
-rw-r--r--src/afl-as.c8
-rw-r--r--src/afl-common.c15
-rw-r--r--src/afl-fuzz.c7
3 files changed, 18 insertions, 12 deletions
diff --git a/src/afl-as.c b/src/afl-as.c
index df487cbc..d4ddb94d 100644
--- a/src/afl-as.c
+++ b/src/afl-as.c
@@ -52,6 +52,7 @@
#include <fcntl.h>
#include <sys/wait.h>
+#include <sys/time.h>
static u8 **as_params; /* Parameters passed to the real 'as' */
@@ -556,7 +557,8 @@ int main(int argc, char **argv) {
int status;
u8 *inst_ratio_str = getenv("AFL_INST_RATIO");
- struct timespec spec;
+ struct timeval tv;
+ struct timezone tz;
clang_mode = !!getenv(CLANG_ENV_VAR);
@@ -607,9 +609,9 @@ int main(int argc, char **argv) {
}
- clock_gettime(CLOCK_REALTIME, &spec);
+ gettimeofday(&tv, &tz);
- rand_seed = spec.tv_sec ^ spec.tv_nsec ^ getpid();
+ rand_seed = tv.tv_sec ^ tv.tv_usec ^ getpid();
// in fast systems where pids can repeat in the same seconds we need this
for (i = 1; (s32)i < argc; i++)
for (j = 0; j < strlen(argv[i]); j++)
diff --git a/src/afl-common.c b/src/afl-common.c
index 62432158..efdb5d60 100644
--- a/src/afl-common.c
+++ b/src/afl-common.c
@@ -976,11 +976,12 @@ void read_bitmap(u8 *fname, u8 *map, size_t len) {
inline u64 get_cur_time(void) {
- struct timespec spec;
+ struct timeval tv;
+ struct timezone tz;
- clock_gettime(CLOCK_REALTIME, &spec);
+ gettimeofday(&tv, &tz);
- return (spec.tv_sec * 1000ULL) + (spec.tv_nsec / 1000000ULL);
+ return (tv.tv_sec * 1000ULL) + (tv.tv_usec / 1000);
}
@@ -988,17 +989,19 @@ inline u64 get_cur_time(void) {
inline u64 get_cur_time_us(void) {
- struct timespec spec;
+ struct timeval tv;
+ struct timezone tz;
- clock_gettime(CLOCK_REALTIME, &spec);
+ gettimeofday(&tv, &tz);
- return (spec.tv_sec * 1000000ULL) + (spec.tv_nsec / 1000ULL);
+ return (tv.tv_sec * 1000000ULL) + tv.tv_usec;
}
/* Describe integer. The buf should be
at least 6 bytes to fit all ints we randomly see.
Will return buf for convenience. */
+
u8 *stringify_int(u8 *buf, size_t len, u64 val) {
\
#define CHK_FORMAT(_divisor, _limit_mult, _fmt, _cast) \
diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c
index 0f84b79b..9867eba3 100644
--- a/src/afl-fuzz.c
+++ b/src/afl-fuzz.c
@@ -555,7 +555,8 @@ int main(int argc, char **argv_orig, char **envp) {
char *frida_afl_preload = NULL;
char **use_argv;
- struct timespec spec;
+ struct timeval tv;
+ struct timezone tz;
doc_path = access(DOC_PATH, F_OK) != 0 ? (u8 *)"docs" : (u8 *)DOC_PATH;
@@ -602,8 +603,8 @@ int main(int argc, char **argv_orig, char **envp) {
SAYF(cCYA "afl-fuzz" VERSION cRST
" based on afl by Michal Zalewski and a large online community\n");
- clock_gettime(CLOCK_REALTIME, &spec);
- rand_set_seed(afl, spec.tv_sec ^ spec.tv_nsec ^ getpid());
+ gettimeofday(&tv, &tz);
+ rand_set_seed(afl, tv.tv_sec ^ tv.tv_usec ^ getpid());
afl->shmem_testcase_mode = 1; // we always try to perform shmem fuzzing