Added out_file value when using stdio
MODIFY
src/afl-forkserver.c
src/afl-forkserver.c
@@ -941,7 +941,7 @@ void afl_fsrv_write_to_testcase(afl_forkserver_t *fsrv, u8 *buf, size_t len) {
s32 fd = fsrv->out_fd;
- if (fsrv->out_file) {
+ if (!fsrv->use_stdin) {
if (fsrv->no_unlink) {
@@ -964,7 +964,7 @@ void afl_fsrv_write_to_testcase(afl_forkserver_t *fsrv, u8 *buf, size_t len) {
ck_write(fd, buf, len, fsrv->out_file);
- if (!fsrv->out_file) {
+ if (fsrv->use_stdin) {
if (ftruncate(fd, len)) { PFATAL("ftruncate() failed"); }
lseek(fd, 0, SEEK_SET);

MODIFY
src/afl-fuzz-init.c
src/afl-fuzz-init.c
@@ -1841,24 +1841,21 @@ void setup_cmdline_file(afl_state_t *afl, char **argv) {
void setup_stdio_file(afl_state_t *afl) {
- u8 *fn;
if (afl->file_extension) {
- fn = alloc_printf("%s/.cur_input.%s", afl->tmp_dir, afl->file_extension);
+ afl->fsrv.out_file = alloc_printf("%s/.cur_input.%s", afl->tmp_dir, afl->file_extension);
} else {
- fn = alloc_printf("%s/.cur_input", afl->tmp_dir);
+ afl->fsrv.out_file = alloc_printf("%s/.cur_input", afl->tmp_dir);
}
- unlink(fn); /* Ignore errors */
-
- afl->fsrv.out_fd = open(fn, O_RDWR | O_CREAT | O_EXCL, 0600);
+ unlink(afl->fsrv.out_file); /* Ignore errors */
- if (afl->fsrv.out_fd < 0) { PFATAL("Unable to create '%s'", fn); }
+ afl->fsrv.out_fd = open(afl->fsrv.out_file, O_RDWR | O_CREAT | O_EXCL, 0600);
- ck_free(fn);
+ if (afl->fsrv.out_fd < 0) { PFATAL("Unable to create '%s'", afl->fsrv.out_file); }
}

Added out_file value when using stdio (#524)