diff options
author | van Hauser <vh@thc.org> | 2019-12-02 15:25:17 +0100 |
---|---|---|
committer | van Hauser <vh@thc.org> | 2019-12-02 15:25:17 +0100 |
commit | f8bc9b54dabc759e9ad1eb82e5ee36af3bb4e1a6 (patch) | |
tree | 25ca944fe68f932c68cae788fb5da6f36f6449c6 /src/afl-fuzz-run.c | |
parent | 60c8121c1d4172528f5713c486d5dd3f809ec8ac (diff) | |
download | afl++-f8bc9b54dabc759e9ad1eb82e5ee36af3bb4e1a6.tar.gz |
added -N no_unlink option
Diffstat (limited to 'src/afl-fuzz-run.c')
-rw-r--r-- | src/afl-fuzz-run.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/src/afl-fuzz-run.c b/src/afl-fuzz-run.c index 8fa91afd..8f72d0fe 100644 --- a/src/afl-fuzz-run.c +++ b/src/afl-fuzz-run.c @@ -288,9 +288,16 @@ void write_to_testcase(void* mem, u32 len) { if (out_file) { - unlink(out_file); /* Ignore errors. */ + if (no_unlink) { - fd = open(out_file, O_WRONLY | O_CREAT | O_EXCL, 0600); + fd = open(out_file, O_WRONLY | O_CREAT | O_TRUNC, 0600); + + } else { + + unlink(out_file); /* Ignore errors. */ + fd = open(out_file, O_WRONLY | O_CREAT | O_EXCL, 0600); + + } if (fd < 0) PFATAL("Unable to create '%s'", out_file); @@ -330,9 +337,16 @@ void write_with_gap(void* mem, u32 len, u32 skip_at, u32 skip_len) { if (out_file) { - unlink(out_file); /* Ignore errors. */ + if (no_unlink) { + + fd = open(out_file, O_WRONLY | O_CREAT | O_TRUNC, 0600); + + } else { - fd = open(out_file, O_WRONLY | O_CREAT | O_EXCL, 0600); + unlink(out_file); /* Ignore errors. */ + fd = open(out_file, O_WRONLY | O_CREAT | O_EXCL, 0600); + + } if (fd < 0) PFATAL("Unable to create '%s'", out_file); @@ -760,9 +774,16 @@ u8 trim_case(char** argv, struct queue_entry* q, u8* in_buf) { s32 fd; - unlink(q->fname); /* ignore errors */ + if (no_unlink) { + + fd = open(q->fname, O_WRONLY | O_CREAT | O_TRUNC, 0600); - fd = open(q->fname, O_WRONLY | O_CREAT | O_EXCL, 0600); + } else { + + unlink(q->fname); /* ignore errors */ + fd = open(q->fname, O_WRONLY | O_CREAT | O_EXCL, 0600); + + } if (fd < 0) PFATAL("Unable to create '%s'", q->fname); |