aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-10-15 15:33:47 +0200
committervan Hauser <vh@thc.org>2020-10-15 15:33:47 +0200
commit354bda28465588e424c0a93b413af01a603191ce (patch)
treea0355a27993d9ae468a5fb7efb5ba6166a89705b /src
parent0f8529a3db242131486cc3bf4a66c024c2b3e126 (diff)
downloadafl++-354bda28465588e424c0a93b413af01a603191ce.tar.gz
fix reget of testcase after trim
Diffstat (limited to 'src')
-rw-r--r--src/afl-fuzz-queue.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/afl-fuzz-queue.c b/src/afl-fuzz-queue.c
index 38d7f77e..095a391f 100644
--- a/src/afl-fuzz-queue.c
+++ b/src/afl-fuzz-queue.c
@@ -875,22 +875,27 @@ void queue_testcase_retake(afl_state_t *afl, struct queue_entry *q,
if (likely(q->testcase_buf)) {
- free(q->testcase_buf);
- int fd = open(q->fname, O_RDONLY);
+ u32 len = q->len;
- if (unlikely(fd < 0)) { PFATAL("Unable to open '%s'", q->fname); }
+ if (len != old_len) {
- u32 len = q->len;
- q->testcase_buf = malloc(len);
+ afl->q_testcase_cache_size =
+ afl->q_testcase_cache_size + q->len - old_len;
+ q->testcase_buf = realloc(q->testcase_buf, len);
+ if (unlikely(!q->testcase_buf)) {
- if (unlikely(!q->testcase_buf)) {
+ PFATAL("Unable to malloc '%s' with len %d", q->fname, len);
- PFATAL("Unable to mmap '%s' with len %d", q->fname, len);
+ }
}
+ int fd = open(q->fname, O_RDONLY);
+
+ if (unlikely(fd < 0)) { PFATAL("Unable to open '%s'", q->fname); }
+
+ ck_read(fd, q->testcase_buf, len, q->fname);
close(fd);
- afl->q_testcase_cache_size = afl->q_testcase_cache_size + q->len - old_len;
}