aboutsummaryrefslogtreecommitdiff
path: root/frida_mode
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 /frida_mode
parent3f26818d973c4929857977b7cdfcf26cc0a84eb3 (diff)
downloadafl++-7c380a6612f00e4a7ed02364dc2b3769e8edc8f8.tar.gz
Replace gettimeofday with clock_gettime (#2159)
Diffstat (limited to 'frida_mode')
-rw-r--r--frida_mode/test/unstable/unstable.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/frida_mode/test/unstable/unstable.c b/frida_mode/test/unstable/unstable.c
index 16978e7e..8466cba0 100644
--- a/frida_mode/test/unstable/unstable.c
+++ b/frida_mode/test/unstable/unstable.c
@@ -14,7 +14,7 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include <sys/time.h>
+#include <time.h>
#ifdef __APPLE__
#define TESTINSTR_SECTION
@@ -22,17 +22,21 @@
#define TESTINSTR_SECTION __attribute__((section(".testinstr")))
#endif
-void LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+void LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size < 1) return;
- struct timeval tv = {0};
- if (gettimeofday(&tv, NULL) < 0) return;
+ struct timespec spec = {0};
+ if (clock_gettime(CLOCK_REALTIME, &spec) < 0) return;
+
+ if ((spec.tv_nsec % 2) == 0) {
+
+ printf("Hooray all even\n");
- if ((tv.tv_usec % 2) == 0) {
- printf ("Hooray all even\n");
} else {
- printf ("Hmm that's odd\n");
+
+ printf("Hmm that's odd\n");
+
}
// we support three input cases
@@ -45,26 +49,33 @@ void LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
}
-void run_test(char * file) {
+void run_test(char *file) {
+
fprintf(stderr, "Running: %s\n", file);
FILE *f = fopen(file, "r");
assert(f);
fseek(f, 0, SEEK_END);
size_t len = ftell(f);
fseek(f, 0, SEEK_SET);
- unsigned char *buf = (unsigned char*)malloc(len);
- size_t n_read = fread(buf, 1, len, f);
+ unsigned char *buf = (unsigned char *)malloc(len);
+ size_t n_read = fread(buf, 1, len, f);
fclose(f);
assert(n_read == len);
LLVMFuzzerTestOneInput(buf, len);
free(buf);
fprintf(stderr, "Done: %s: (%zd bytes)\n", file, n_read);
+
}
int main(int argc, char **argv) {
+
srand(1);
fprintf(stderr, "StandaloneFuzzTargetMain: running %d inputs\n", argc - 1);
for (int i = 1; i < argc; i++) {
+
run_test(argv[i]);
+
}
+
}
+