about summary refs log tree commit diff
path: root/src/afl-fuzz-extras.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-04-17 19:25:34 +0200
committerGitHub <noreply@github.com>2020-04-17 19:25:34 +0200
commitddea300822e5628482366ecb38adac31717d69bc (patch)
tree113c1ba9df4b26d206a8bc0f3182222572e5f553 /src/afl-fuzz-extras.c
parent504529c3aa5c80937f9f722f90d0ec55e09c6dd2 (diff)
parent9900c92ebc73a7706f4604c274ccf6430549e77e (diff)
downloadafl++-ddea300822e5628482366ecb38adac31717d69bc.tar.gz
Merge pull request #321 from AFLplusplus/dev 2.64c
Push for next release
Diffstat (limited to 'src/afl-fuzz-extras.c')
-rw-r--r--src/afl-fuzz-extras.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/afl-fuzz-extras.c b/src/afl-fuzz-extras.c
index 16806934..c366cc5b 100644
--- a/src/afl-fuzz-extras.c
+++ b/src/afl-fuzz-extras.c
@@ -130,6 +130,8 @@ void load_extras_file(afl_state_t *afl, u8 *fname, u32 *min_len, u32 *max_len,
 
     wptr = afl->extras[afl->extras_cnt].data = ck_alloc(rptr - lptr);
 
+    if (!wptr) PFATAL("no mem for data");
+
     while (*lptr) {
 
       char *hexdigits = "0123456789abcdef";
@@ -305,10 +307,14 @@ static inline u8 memcmp_nocase(u8 *m1, u8 *m2, u32 len) {
 }
 
 /* Maybe add automatic extra. */
+/* Ugly hack: afl state is transfered as u8* because we import data via
+   afl-forkserver.c - which is shared with other afl tools that do not
+   have the afl state struct */
 
-void maybe_add_auto(afl_state_t *afl, u8 *mem, u32 len) {
+void maybe_add_auto(void *afl_tmp, u8 *mem, u32 len) {
 
-  u32 i;
+  afl_state_t *afl = (afl_state_t *)afl_tmp;
+  u32          i;
 
   /* Allow users to specify that they don't want auto dictionaries. */
 
@@ -469,7 +475,7 @@ void load_auto(afl_state_t *afl) {
     if (len < 0) PFATAL("Unable to read from '%s'", fn);
 
     if (len >= MIN_AUTO_EXTRA && len <= MAX_AUTO_EXTRA)
-      maybe_add_auto(afl, tmp, len);
+      maybe_add_auto((u8 *)afl, tmp, len);
 
     close(fd);
     ck_free(fn);