From a05bd3e477a09dc8e56b18eac9c6c163a4eefd8b Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Wed, 25 Dec 2019 10:42:23 +0100 Subject: code format --- src/afl-analyze.c | 15 +++++++++------ src/afl-fuzz.c | 10 +++++++--- src/afl-showmap.c | 15 +++++++++------ src/afl-tmin.c | 15 +++++++++------ 4 files changed, 34 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/afl-analyze.c b/src/afl-analyze.c index 0a9b4785..f71893d8 100644 --- a/src/afl-analyze.c +++ b/src/afl-analyze.c @@ -716,11 +716,15 @@ static void set_up_environment(void) { u8* qemu_preload = getenv("QEMU_SET_ENV"); u8* afl_preload = getenv("AFL_PRELOAD"); u8* buf; - + s32 i, afl_preload_size = strlen(afl_preload); for (i = 0; i < afl_preload_size; ++i) { + if (afl_preload[i] == ',') - PFATAL("Comma (',') is not allowed in AFL_PRELOAD when -Q is specified!"); + PFATAL( + "Comma (',') is not allowed in AFL_PRELOAD when -Q is " + "specified!"); + } if (qemu_preload) @@ -729,7 +733,7 @@ static void set_up_environment(void) { buf = alloc_printf("LD_PRELOAD=%s", afl_preload); setenv("QEMU_SET_ENV", buf, 1); - + ck_free(buf); } else { @@ -861,9 +865,8 @@ static void find_binary(u8* fname) { int main(int argc, char** argv) { - s32 opt; - u8 mem_limit_given = 0, timeout_given = 0, unicorn_mode = 0, - use_wine = 0; + s32 opt; + u8 mem_limit_given = 0, timeout_given = 0, unicorn_mode = 0, use_wine = 0; char** use_argv; doc_path = access(DOC_PATH, F_OK) ? "docs" : DOC_PATH; diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 7df82b12..ebc11f01 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -717,11 +717,15 @@ int main(int argc, char** argv) { u8* qemu_preload = getenv("QEMU_SET_ENV"); u8* afl_preload = getenv("AFL_PRELOAD"); u8* buf; - + s32 i, afl_preload_size = strlen(afl_preload); for (i = 0; i < afl_preload_size; ++i) { + if (afl_preload[i] == ',') - PFATAL("Comma (',') is not allowed in AFL_PRELOAD when -Q is specified!"); + PFATAL( + "Comma (',') is not allowed in AFL_PRELOAD when -Q is " + "specified!"); + } if (qemu_preload) @@ -730,7 +734,7 @@ int main(int argc, char** argv) { buf = alloc_printf("LD_PRELOAD=%s", afl_preload); setenv("QEMU_SET_ENV", buf, 1); - + ck_free(buf); } else { diff --git a/src/afl-showmap.c b/src/afl-showmap.c index 0e3e5351..94bbd421 100644 --- a/src/afl-showmap.c +++ b/src/afl-showmap.c @@ -365,11 +365,15 @@ static void set_up_environment(void) { u8* qemu_preload = getenv("QEMU_SET_ENV"); u8* afl_preload = getenv("AFL_PRELOAD"); u8* buf; - + s32 i, afl_preload_size = strlen(afl_preload); for (i = 0; i < afl_preload_size; ++i) { + if (afl_preload[i] == ',') - PFATAL("Comma (',') is not allowed in AFL_PRELOAD when -Q is specified!"); + PFATAL( + "Comma (',') is not allowed in AFL_PRELOAD when -Q is " + "specified!"); + } if (qemu_preload) @@ -378,7 +382,7 @@ static void set_up_environment(void) { buf = alloc_printf("LD_PRELOAD=%s", afl_preload); setenv("QEMU_SET_ENV", buf, 1); - + ck_free(buf); } else { @@ -524,9 +528,8 @@ static void find_binary(u8* fname) { int main(int argc, char** argv) { - s32 opt; - u8 mem_limit_given = 0, timeout_given = 0, unicorn_mode = 0, - use_wine = 0; + s32 opt; + u8 mem_limit_given = 0, timeout_given = 0, unicorn_mode = 0, use_wine = 0; u32 tcnt = 0; char** use_argv; diff --git a/src/afl-tmin.c b/src/afl-tmin.c index 3230c952..b98208f9 100644 --- a/src/afl-tmin.c +++ b/src/afl-tmin.c @@ -889,11 +889,15 @@ static void set_up_environment(void) { u8* qemu_preload = getenv("QEMU_SET_ENV"); u8* afl_preload = getenv("AFL_PRELOAD"); u8* buf; - + s32 i, afl_preload_size = strlen(afl_preload); for (i = 0; i < afl_preload_size; ++i) { + if (afl_preload[i] == ',') - PFATAL("Comma (',') is not allowed in AFL_PRELOAD when -Q is specified!"); + PFATAL( + "Comma (',') is not allowed in AFL_PRELOAD when -Q is " + "specified!"); + } if (qemu_preload) @@ -902,7 +906,7 @@ static void set_up_environment(void) { buf = alloc_printf("LD_PRELOAD=%s", afl_preload); setenv("QEMU_SET_ENV", buf, 1); - + ck_free(buf); } else { @@ -1052,9 +1056,8 @@ static void read_bitmap(u8* fname) { int main(int argc, char** argv) { - s32 opt; - u8 mem_limit_given = 0, timeout_given = 0, unicorn_mode = 0, - use_wine = 0; + s32 opt; + u8 mem_limit_given = 0, timeout_given = 0, unicorn_mode = 0, use_wine = 0; char** use_argv; doc_path = access(DOC_PATH, F_OK) ? "docs" : DOC_PATH; -- cgit 1.4.1 From cc3bf762ece81fb1007bc368f4bd604804afd095 Mon Sep 17 00:00:00 2001 From: n0p <0x90@n0p.cc> Date: Fri, 27 Dec 2019 18:50:14 +0100 Subject: Fixed memory leak in afl-fuzz-python.c - trim_case_python. --- src/afl-fuzz-python.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/afl-fuzz-python.c b/src/afl-fuzz-python.c index 73fcd138..53935698 100644 --- a/src/afl-fuzz-python.c +++ b/src/afl-fuzz-python.c @@ -345,7 +345,10 @@ u8 trim_case_python(char** argv, struct queue_entry* q, u8* in_buf) { fault = run_target(argv, exec_tmout); ++trim_execs; - if (stop_soon || fault == FAULT_ERROR) goto abort_trimming; + if (stop_soon || fault == FAULT_ERROR) { + free(retbuf); + goto abort_trimming; + } cksum = hash32(trace_bits, MAP_SIZE, HASH_CONST); @@ -381,6 +384,8 @@ u8 trim_case_python(char** argv, struct queue_entry* q, u8* in_buf) { } + free(retbuf); + /* Since this can be slow, update the screen every now and then. */ if (!(trim_exec++ % stats_update_freq)) show_stats(); -- cgit 1.4.1 From c983e2c5b1c47618a4fac58154cb06020b31bbe3 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Sat, 28 Dec 2019 11:42:06 +0100 Subject: code format --- experimental/socket_fuzzing/socketfuzz.c | 5 ++++- src/afl-fuzz-python.c | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/experimental/socket_fuzzing/socketfuzz.c b/experimental/socket_fuzzing/socketfuzz.c index 9667cd70..3ec8383b 100644 --- a/experimental/socket_fuzzing/socketfuzz.c +++ b/experimental/socket_fuzzing/socketfuzz.c @@ -96,7 +96,8 @@ int listen(int sockfd, int backlog) { } -int setsockopt(int sockfd, int level, int optid, const void *optdata, socklen_t optdatalen) { +int setsockopt(int sockfd, int level, int optid, const void *optdata, + socklen_t optdatalen) { (void)sockfd; (void)level; @@ -104,4 +105,6 @@ int setsockopt(int sockfd, int level, int optid, const void *optdata, socklen_t (void)optdata; (void)optdatalen; return 0; + } + diff --git a/src/afl-fuzz-python.c b/src/afl-fuzz-python.c index 53935698..6800c0c0 100644 --- a/src/afl-fuzz-python.c +++ b/src/afl-fuzz-python.c @@ -346,8 +346,10 @@ u8 trim_case_python(char** argv, struct queue_entry* q, u8* in_buf) { ++trim_execs; if (stop_soon || fault == FAULT_ERROR) { - free(retbuf); - goto abort_trimming; + + free(retbuf); + goto abort_trimming; + } cksum = hash32(trace_bits, MAP_SIZE, HASH_CONST); -- cgit 1.4.1