aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-11-18 21:25:35 +0100
committerGitHub <noreply@github.com>2020-11-18 21:25:35 +0100
commit4d9eb9bda147a26fc8cbe885b6193cf0c94c6314 (patch)
treec7a903633c7d1b0b5e373535188fd3a458a7f329 /examples
parent4c59c5234aec0469e4dd02561dbd84387bd53155 (diff)
parentcd0a25be5e9b05a2ab6a11592cd95e7f653bf42d (diff)
downloadafl++-4d9eb9bda147a26fc8cbe885b6193cf0c94c6314.tar.gz
Merge pull request #607 from AFLplusplus/dev
push to stable
Diffstat (limited to 'examples')
-rw-r--r--examples/afl_frida/afl-frida.c7
-rw-r--r--examples/afl_network_proxy/afl-network-server.c15
-rw-r--r--examples/custom_mutators/custom_mutator_helpers.h2
-rw-r--r--examples/custom_mutators/post_library_gif.so.c8
-rw-r--r--examples/custom_mutators/post_library_png.so.c8
-rw-r--r--examples/custom_mutators/simple_example.c2
-rw-r--r--examples/defork/forking_target.c1
7 files changed, 30 insertions, 13 deletions
diff --git a/examples/afl_frida/afl-frida.c b/examples/afl_frida/afl-frida.c
index 2ad5a72a..31bf8f25 100644
--- a/examples/afl_frida/afl-frida.c
+++ b/examples/afl_frida/afl-frida.c
@@ -6,7 +6,7 @@
Written mostly by meme -> https://github.com/meme/hotwax
- Modificationy by Marc Heuse <mh@mh-sec.de>
+ Modifications by Marc Heuse <mh@mh-sec.de>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -504,11 +504,12 @@ int main() {
previous_pc = 0; // Required!
#ifdef _DEBUG
- fprintf(stderr, "CLIENT crc: %016llx len: %u\n", hash64(__afl_fuzz_ptr, *__a
+ fprintf(stderr, "CLIENT crc: %016llx len: %u\n",
+ hash64(__afl_fuzz_ptr, *__afl_fuzz_len), *__afl_fuzz_len);
fprintf(stderr, "RECV:");
for (int i = 0; i < *__afl_fuzz_len; i++)
fprintf(stderr, "%02x", __afl_fuzz_ptr[i]);
- fprintf(stderr,"\n");
+ fprintf(stderr, "\n");
#endif
// STEP 3: ensure the minimum length is present and setup the target
diff --git a/examples/afl_network_proxy/afl-network-server.c b/examples/afl_network_proxy/afl-network-server.c
index 75eb3d20..513dc8f2 100644
--- a/examples/afl_network_proxy/afl-network-server.c
+++ b/examples/afl_network_proxy/afl-network-server.c
@@ -358,8 +358,8 @@ int recv_testcase(int s, void **buf) {
if ((size & 0xff000000) != 0xff000000) {
- *buf = afl_realloc((void **)&buf, size);
- if (unlikely(!buf)) { PFATAL("Alloc"); }
+ *buf = afl_realloc(buf, size);
+ if (unlikely(!*buf)) { PFATAL("Alloc"); }
received = 0;
// fprintf(stderr, "unCOMPRESS (%u)\n", size);
while (received < size &&
@@ -371,8 +371,8 @@ int recv_testcase(int s, void **buf) {
#ifdef USE_DEFLATE
u32 clen;
size -= 0xff000000;
- *buf = afl_realloc((void **)&buf, size);
- if (unlikely(!buf)) { PFATAL("Alloc"); }
+ *buf = afl_realloc(buf, size);
+ if (unlikely(!*buf)) { PFATAL("Alloc"); }
received = 0;
while (received < 4 &&
(ret = recv(s, &clen + received, 4 - received, 0)) > 0)
@@ -636,8 +636,11 @@ int main(int argc, char **argv_orig, char **envp) {
if (listen(sock, 1) < 0) { PFATAL("listen() failed"); }
- afl_fsrv_start(fsrv, use_argv, &stop_soon,
- get_afl_env("AFL_DEBUG_CHILD_OUTPUT") ? 1 : 0);
+ afl_fsrv_start(
+ fsrv, use_argv, &stop_soon,
+ (get_afl_env("AFL_DEBUG_CHILD") || get_afl_env("AFL_DEBUG_CHILD_OUTPUT"))
+ ? 1
+ : 0);
#ifdef USE_DEFLATE
compressor = libdeflate_alloc_compressor(1);
diff --git a/examples/custom_mutators/custom_mutator_helpers.h b/examples/custom_mutators/custom_mutator_helpers.h
index ad5acb08..62e6efba 100644
--- a/examples/custom_mutators/custom_mutator_helpers.h
+++ b/examples/custom_mutators/custom_mutator_helpers.h
@@ -13,7 +13,7 @@
#define BUF_VAR(type, name) \
type * name##_buf; \
size_t name##_size;
-/* this filles in `&structptr->something_buf, &structptr->something_size`. */
+/* this fills in `&structptr->something_buf, &structptr->something_size`. */
#define BUF_PARAMS(struct, name) \
(void **)&struct->name##_buf, &struct->name##_size
diff --git a/examples/custom_mutators/post_library_gif.so.c b/examples/custom_mutators/post_library_gif.so.c
index 2d72400c..ac10f409 100644
--- a/examples/custom_mutators/post_library_gif.so.c
+++ b/examples/custom_mutators/post_library_gif.so.c
@@ -94,7 +94,13 @@ void *afl_custom_init(void *afl) {
}
state->buf = calloc(sizeof(unsigned char), 4096);
- if (!state->buf) { return NULL; }
+ if (!state->buf) {
+
+ free(state);
+ perror("calloc");
+ return NULL;
+
+ }
return state;
diff --git a/examples/custom_mutators/post_library_png.so.c b/examples/custom_mutators/post_library_png.so.c
index 7c1ea93e..941f7e55 100644
--- a/examples/custom_mutators/post_library_png.so.c
+++ b/examples/custom_mutators/post_library_png.so.c
@@ -54,7 +54,13 @@ void *afl_custom_init(void *afl) {
}
state->buf = calloc(sizeof(unsigned char), 4096);
- if (!state->buf) { return NULL; }
+ if (!state->buf) {
+
+ free(state);
+ perror("calloc");
+ return NULL;
+
+ }
return state;
diff --git a/examples/custom_mutators/simple_example.c b/examples/custom_mutators/simple_example.c
index a351d787..d888ec1f 100644
--- a/examples/custom_mutators/simple_example.c
+++ b/examples/custom_mutators/simple_example.c
@@ -8,7 +8,7 @@
#include <stdio.h>
#ifndef _FIXED_CHAR
- #define 0x41
+ #define _FIXED_CHAR 0x41
#endif
typedef struct my_mutator {
diff --git a/examples/defork/forking_target.c b/examples/defork/forking_target.c
index 98f6365a..628d23c9 100644
--- a/examples/defork/forking_target.c
+++ b/examples/defork/forking_target.c
@@ -26,6 +26,7 @@ int main(int argc, char **argv) {
FILE *f = fopen(argv[1], "r");
char buf[4096];
fread(buf, 1, 4096, f);
+ fclose(f);
uint32_t offset = buf[100] + (buf[101] << 8);
char test_val = buf[offset];
return test_val < 100;