aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2021-01-23 10:01:09 +0100
committervan Hauser <vh@thc.org>2021-01-23 10:01:09 +0100
commit0a3a708f9bf7b9f192d236c792a13cec2aa54a16 (patch)
treeea98116eae879b454cc09cf4b7edbe077e43d087
parenta22c8ffdf28f19a6b5a43804d2d288dd8b32a0d2 (diff)
downloadafl++-0a3a708f9bf7b9f192d236c792a13cec2aa54a16.tar.gz
less stack mem req
-rw-r--r--src/afl-fuzz-init.c3
-rw-r--r--src/afl-fuzz-queue.c7
2 files changed, 6 insertions, 4 deletions
diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c
index b1a24f2f..fed58eb6 100644
--- a/src/afl-fuzz-init.c
+++ b/src/afl-fuzz-init.c
@@ -807,10 +807,10 @@ void perform_dry_run(afl_state_t *afl) {
struct queue_entry *q = afl->queue;
u32 cal_failures = 0;
u8 * skip_crashes = afl->afl_env.afl_skip_crashes;
+ u8 * use_mem;
while (q) {
- u8 *use_mem = afl_realloc(AFL_BUF_PARAM(in), MAX_FILE);
u8 res;
s32 fd;
@@ -829,6 +829,7 @@ void perform_dry_run(afl_state_t *afl) {
if (fd < 0) { PFATAL("Unable to open '%s'", q->fname); }
u32 read_len = MIN(q->len, (u32)MAX_FILE);
+ use_mem = afl_realloc(AFL_BUF_PARAM(in), read_len);
if (read(fd, use_mem, read_len) != (ssize_t)read_len) {
FATAL("Short read from '%s'", q->fname);
diff --git a/src/afl-fuzz-queue.c b/src/afl-fuzz-queue.c
index aec57a6e..90f969d9 100644
--- a/src/afl-fuzz-queue.c
+++ b/src/afl-fuzz-queue.c
@@ -313,17 +313,18 @@ void mark_as_redundant(afl_state_t *afl, struct queue_entry *q, u8 state) {
/* check if ascii or UTF-8 */
-static u8 check_if_text(struct queue_entry *q) {
+static u8 check_if_text(afl_state_t *afl, struct queue_entry *q) {
if (q->len < AFL_TXT_MIN_LEN) return 0;
- u8 buf[MAX_FILE];
+ u8 *buf;
int fd;
u32 len = q->len, offset = 0, ascii = 0, utf8 = 0;
ssize_t comp;
if (len >= MAX_FILE) len = MAX_FILE - 1;
if ((fd = open(q->fname, O_RDONLY)) < 0) return 0;
+ buf = afl_realloc(AFL_BUF_PARAM(in_scratch), len);
comp = read(fd, buf, len);
close(fd);
if (comp != (ssize_t)len) return 0;
@@ -487,7 +488,7 @@ void add_to_queue(afl_state_t *afl, u8 *fname, u32 len, u8 passed_det) {
}
/* only redqueen currently uses is_ascii */
- if (afl->shm.cmplog_mode) q->is_ascii = check_if_text(q);
+ if (afl->shm.cmplog_mode) q->is_ascii = check_if_text(afl, q);
}