Don't crash for unset out_file (fixed #562)

This commit is contained in:
Dominik Maier
2020-10-29 11:05:07 +01:00
parent abac876b3a
commit 9347ad49b8

View File

@ -968,7 +968,7 @@ void afl_fsrv_write_to_testcase(afl_forkserver_t *fsrv, u8 *buf, size_t len) {
s32 fd = fsrv->out_fd; s32 fd = fsrv->out_fd;
if (!fsrv->use_stdin) { if (!fsrv->use_stdin && fsrv->out_file) {
if (fsrv->no_unlink) { if (fsrv->no_unlink) {
@ -983,6 +983,11 @@ void afl_fsrv_write_to_testcase(afl_forkserver_t *fsrv, u8 *buf, size_t len) {
if (fd < 0) { PFATAL("Unable to create '%s'", fsrv->out_file); } if (fd < 0) { PFATAL("Unable to create '%s'", fsrv->out_file); }
} else if (unlikely(!fd)) {
// We should never have stdin as fd here, 0 is likely unset.
FATAL("Nowhere to write output to (neither out_fd nor out_file set)");
} else { } else {
lseek(fd, 0, SEEK_SET); lseek(fd, 0, SEEK_SET);