aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Maier <domenukk@gmail.com>2020-11-03 13:41:06 +0100
committerDominik Maier <domenukk@gmail.com>2020-11-03 13:41:06 +0100
commitd795ec0451bfb6f93485c4ec6436ae1af3840070 (patch)
treef3d929755b98483be06114f40df6c69c6746197b
parent350c3b323a59c99891635a233c3f82f83653947c (diff)
downloadafl++-d795ec0451bfb6f93485c4ec6436ae1af3840070.tar.gz
added better error handling to forkserver fd
-rw-r--r--.gitignore5
-rw-r--r--include/debug.h16
-rw-r--r--src/afl-forkserver.c9
3 files changed, 20 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index fb6a94c1..8107b448 100644
--- a/.gitignore
+++ b/.gitignore
@@ -76,3 +76,8 @@ examples/afl_frida/afl-frida
examples/afl_frida/libtestinstr.so
examples/afl_frida/frida-gum-example.c
examples/afl_frida/frida-gum.h
+examples/aflpp_driver/libAFLDriver.a
+examples/aflpp_driver/libAFLQemuDriver.a
+libAFLDriver.a
+libAFLQemuDriver.a
+test/.afl_performance \ No newline at end of file
diff --git a/include/debug.h b/include/debug.h
index f9ebce58..e6d3c3fc 100644
--- a/include/debug.h
+++ b/include/debug.h
@@ -273,13 +273,15 @@
/* Error-checking versions of read() and write() that call RPFATAL() as
appropriate. */
-#define ck_write(fd, buf, len, fn) \
- do { \
- \
- s32 _len = (s32)(len); \
- s32 _res = write(fd, buf, _len); \
- if (_res != _len) RPFATAL(_res, "Short write to %s", fn); \
- \
+#define ck_write(fd, buf, len, fn) \
+ do { \
+ \
+ int _fd = (fd); \
+ \
+ s32 _len = (s32)(len); \
+ s32 _res = write(_fd, (buf), _len); \
+ if (_res != _len) RPFATAL(_res, "Short write to %s, fd %d", fn, _fd); \
+ \
} while (0)
#define ck_read(fd, buf, len, fn) \
diff --git a/src/afl-forkserver.c b/src/afl-forkserver.c
index d23cf6eb..714be24e 100644
--- a/src/afl-forkserver.c
+++ b/src/afl-forkserver.c
@@ -983,10 +983,13 @@ 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)) {
+ } else if (unlikely(fd <= 0)) {
- // 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)");
+ // We should have a (non-stdin) fd at this point, else we got a problem.
+ FATAL(
+ "Nowhere to write output to (neither out_fd nor out_file set (fd is "
+ "%d))",
+ fd);
} else {