Don't crash for unset out_file (fixed
MODIFY
src/afl-forkserver.c
src/afl-forkserver.c
@@ -968,7 +968,7 @@ void afl_fsrv_write_to_testcase(afl_forkserver_t *fsrv, u8 *buf, size_t len) {
s32 fd = fsrv->out_fd;
- if (!fsrv->use_stdin) {
+ if (!fsrv->use_stdin && fsrv->out_file) {
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); }
+ } 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 {
lseek(fd, 0, SEEK_SET);

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