aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2022-04-25 10:14:19 +0200
committerGitHub <noreply@github.com>2022-04-25 10:14:19 +0200
commitc7bb0a9638a8929a5b664f16032c23a55a84be70 (patch)
tree2fb8cee9897c46a53e756e898de732c63f2a8842 /include
parentac80678592ea4a790ab2eedccfec4e3bc9f96447 (diff)
parentee409d18a6678c3f5948f51db8964148cae021dc (diff)
downloadafl++-c7bb0a9638a8929a5b664f16032c23a55a84be70.tar.gz
Merge pull request #1392 from AFLplusplus/dev
push to stable
Diffstat (limited to 'include')
-rw-r--r--include/afl-fuzz.h2
-rw-r--r--include/debug.h47
-rw-r--r--include/envs.h1
3 files changed, 35 insertions, 15 deletions
diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h
index 4f4d63b2..8bb61e22 100644
--- a/include/afl-fuzz.h
+++ b/include/afl-fuzz.h
@@ -385,7 +385,7 @@ typedef struct afl_env_vars {
afl_bench_until_crash, afl_debug_child, afl_autoresume, afl_cal_fast,
afl_cycle_schedules, afl_expand_havoc, afl_statsd, afl_cmplog_only_new,
afl_exit_on_seed_issues, afl_try_affinity, afl_ignore_problems,
- afl_pizza_mode;
+ afl_keep_timeouts, afl_pizza_mode;
u8 *afl_tmpdir, *afl_custom_mutator_library, *afl_python_module, *afl_path,
*afl_hang_tmout, *afl_forksrv_init_tmout, *afl_preload,
diff --git a/include/debug.h b/include/debug.h
index 31ebd0f2..e2ee16a8 100644
--- a/include/debug.h
+++ b/include/debug.h
@@ -355,20 +355,39 @@ static inline const char *colorfilter(const char *x) {
/* Error-checking versions of read() and write() that call RPFATAL() as
appropriate. */
-#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 (%d of %d bytes)", fn, _fd, \
- _res, _len); \
- \
- } \
- \
+#define ck_write(fd, buf, len, fn) \
+ do { \
+ \
+ if (len <= 0) break; \
+ int _fd = (fd); \
+ s32 _written = 0, _off = 0, _len = (s32)(len); \
+ \
+ do { \
+ \
+ s32 _res = write(_fd, (buf) + _off, _len); \
+ if (_res != _len && (_res > 0 && _written + _res != _len)) { \
+ \
+ if (_res > 0) { \
+ \
+ _written += _res; \
+ _len -= _res; \
+ _off += _res; \
+ \
+ } else { \
+ \
+ RPFATAL(_res, "Short write to %s, fd %d (%d of %d bytes)", fn, _fd, \
+ _res, _len); \
+ \
+ } \
+ \
+ } else { \
+ \
+ break; \
+ \
+ } \
+ \
+ } while (1); \
+ \
} while (0)
#define ck_read(fd, buf, len, fn) \
diff --git a/include/envs.h b/include/envs.h
index 1746f946..25b792fa 100644
--- a/include/envs.h
+++ b/include/envs.h
@@ -106,6 +106,7 @@ static char *afl_environment_variables[] = {
"AFL_INPUT_LEN_MAX",
"AFL_INST_LIBS",
"AFL_INST_RATIO",
+ "AFL_KEEP_TIMEOUTS",
"AFL_KILL_SIGNAL",
"AFL_KEEP_TRACES",
"AFL_KEEP_ASSEMBLY",