diff options
author | vanhauser-thc <vh@thc.org> | 2022-04-22 10:28:14 +0200 |
---|---|---|
committer | vanhauser-thc <vh@thc.org> | 2022-04-22 10:28:21 +0200 |
commit | 7f26d133458f5034499f40129e9a5517cee21cce (patch) | |
tree | 2cd01d3b019350de759c6f0478465197632bbab2 | |
parent | 5798c686b20ac47c4fc7f939c02ee211108c0f1f (diff) | |
download | afl++-7f26d133458f5034499f40129e9a5517cee21cce.tar.gz |
try repeating write
-rw-r--r-- | GNUmakefile | 2 | ||||
m--------- | custom_mutators/grammar_mutator/grammar_mutator | 0 | ||||
-rw-r--r-- | include/debug.h | 47 | ||||
m--------- | unicorn_mode/unicornafl | 0 |
4 files changed, 34 insertions, 15 deletions
diff --git a/GNUmakefile b/GNUmakefile index ec81cbac..8b09c51a 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -145,7 +145,7 @@ else CFLAGS ?= -O2 $(CFLAGS_OPT) # -funroll-loops is slower on modern compilers endif -override CFLAGS += -g -Wno-pointer-sign -Wno-variadic-macros -Wall -Wextra -Wpointer-arith \ +override CFLAGS += -g -Wno-pointer-sign -Wno-variadic-macros -Wall -Wextra -Wno-pointer-arith \ -fPIC -I include/ -DAFL_PATH=\"$(HELPER_PATH)\" \ -DBIN_PATH=\"$(BIN_PATH)\" -DDOC_PATH=\"$(DOC_PATH)\" # -fstack-protector diff --git a/custom_mutators/grammar_mutator/grammar_mutator b/custom_mutators/grammar_mutator/grammar_mutator -Subproject cbe5e32752773945e0142fac9f1b7a0ccb5dcdf +Subproject ff4e5a265daf5d88c4a636fb6a2c22b1d733db0 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/unicorn_mode/unicornafl b/unicorn_mode/unicornafl -Subproject d4915053d477dd827b3fe4b494173d3fbf9f456 +Subproject a44fa94488d01aba60401ccf81f8bebcce685bf |