From b7a2c7e6988f519f45e2305f2745355f6c3dd4ae Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Thu, 15 Sep 2022 10:13:46 +0200 Subject: try LLVMFuzzerRunDriver support --- utils/aflpp_driver/aflpp_driver.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'utils/aflpp_driver/aflpp_driver.c') diff --git a/utils/aflpp_driver/aflpp_driver.c b/utils/aflpp_driver/aflpp_driver.c index 4e4ea129..69379061 100644 --- a/utils/aflpp_driver/aflpp_driver.c +++ b/utils/aflpp_driver/aflpp_driver.c @@ -64,6 +64,8 @@ extern unsigned char *__afl_fuzz_ptr; // libFuzzer interface is thin, so we don't include any libFuzzer headers. int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size); __attribute__((weak)) int LLVMFuzzerInitialize(int *argc, char ***argv); +int LLVMFuzzerRunDriver(int *argc, char ***argv, + int (*callback)(const uint8_t *data, size_t size)); // Default nop ASan hooks for manual posisoning when not linking the ASan // runtime @@ -245,7 +247,7 @@ static int ExecuteFilesOnyByOne(int argc, char **argv) { } -int main(int argc, char **argv) { +__attribute__((weak)) int main(int argc, char **argv) { if (argc < 2 || strncmp(argv[1], "-h", 2) == 0) printf( @@ -265,6 +267,16 @@ int main(int argc, char **argv) { "===================================================================\n", argv[0], argv[0]); + return LLVMFuzzerRunDriver(&argc, &argv, LLVMFuzzerTestOneInput); + +} + +int LLVMFuzzerRunDriver(int *argcp, char ***argvp, + int (*callback)(const uint8_t *data, size_t size)) { + + int argc = *argcp; + char **argv = *argvp; + if (getenv("AFL_GDB")) { char cmd[64]; -- cgit 1.4.1 From 636025df9a583541168ae1dea3d412c8168fe0f9 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Thu, 15 Sep 2022 10:32:34 +0200 Subject: forgot correct callback --- utils/aflpp_driver/aflpp_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/aflpp_driver/aflpp_driver.c') diff --git a/utils/aflpp_driver/aflpp_driver.c b/utils/aflpp_driver/aflpp_driver.c index 69379061..f2d07190 100644 --- a/utils/aflpp_driver/aflpp_driver.c +++ b/utils/aflpp_driver/aflpp_driver.c @@ -364,7 +364,7 @@ int LLVMFuzzerRunDriver(int *argcp, char ***argvp, } prev_length = length; - LLVMFuzzerTestOneInput(__afl_fuzz_ptr, length); + (void)callback(__afl_fuzz_ptr, length); } -- cgit 1.4.1 From af5e8370af3b8a1e1077ca735b0748f7c5b988bb Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Fri, 16 Sep 2022 10:57:13 +0200 Subject: fix LLVMFuzzerRunDriver --- unicorn_mode/unicornafl | 2 +- utils/aflpp_driver/aflpp_driver.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'utils/aflpp_driver/aflpp_driver.c') diff --git a/unicorn_mode/unicornafl b/unicorn_mode/unicornafl index 6e00ceac..06796154 160000 --- a/unicorn_mode/unicornafl +++ b/unicorn_mode/unicornafl @@ -1 +1 @@ -Subproject commit 6e00ceac6fd5627e42e1858c543c84f2fbdaedda +Subproject commit 06796154996fef2d92ccd172181ee0cdf3631959 diff --git a/utils/aflpp_driver/aflpp_driver.c b/utils/aflpp_driver/aflpp_driver.c index f2d07190..52b98f41 100644 --- a/utils/aflpp_driver/aflpp_driver.c +++ b/utils/aflpp_driver/aflpp_driver.c @@ -62,7 +62,8 @@ extern unsigned int *__afl_fuzz_len; extern unsigned char *__afl_fuzz_ptr; // libFuzzer interface is thin, so we don't include any libFuzzer headers. -int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size); +__attribute__((weak)) int LLVMFuzzerTestOneInput(const uint8_t *Data, + size_t Size); __attribute__((weak)) int LLVMFuzzerInitialize(int *argc, char ***argv); int LLVMFuzzerRunDriver(int *argc, char ***argv, int (*callback)(const uint8_t *data, size_t size)); -- cgit 1.4.1