diff options
author | Dominik Maier <domenukk@gmail.com> | 2020-05-29 18:58:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-29 18:58:25 +0200 |
commit | 408ef5298bd2f233649dd6799757369e963b0a24 (patch) | |
tree | 3d4e66ad80c81c1ab658f349dbf4894d6f848b7f | |
parent | 2ce243bc6eee4b9d5830bf04369881cb8ee7f93b (diff) | |
parent | 4b01d594c40b4e59414413152392963f3cf5247d (diff) | |
download | afl++-408ef5298bd2f233649dd6799757369e963b0a24.tar.gz |
Merge pull request #383 from dgmelski/fix-read-timed
Fix read_timed when accumulating short reads
-rw-r--r-- | GNUmakefile | 2 | ||||
-rw-r--r-- | src/afl-common.c | 8 | ||||
-rwxr-xr-x | test/test.sh | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/GNUmakefile b/GNUmakefile index 8f559391..dd817d35 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -101,7 +101,7 @@ endif ifeq "$(shell uname -s)" "OpenBSD" override CFLAGS += -I /usr/local/include/ - LDFLAGS += -L /usr/local/lib/ + LDFLAGS += -Wl,-z,notext -L /usr/local/lib/ endif ifeq "$(shell uname -s)" "NetBSD" diff --git a/src/afl-common.c b/src/afl-common.c index 1bb58a60..9fd4bf03 100644 --- a/src/afl-common.c +++ b/src/afl-common.c @@ -885,9 +885,9 @@ u32 read_timed(s32 fd, void *buf, size_t len, u32 timeout_ms, timeout.tv_usec = (timeout_ms % 1000) * 1000; size_t read_total = 0; - size_t len_read = 0; + ssize_t len_read = 0; - while (len_read < len) { + while (read_total < len) { /* set exceptfds as well to return when a child exited/closed the pipe. */ int sret = select(fd + 1, &readfds, NULL, NULL, &timeout); @@ -905,8 +905,8 @@ u32 read_timed(s32 fd, void *buf, size_t len, u32 timeout_ms, } - len_read = read(fd, ((u8 *)buf) + len_read, len - len_read); - if (!len_read) { return 0; } + len_read = read(fd, ((u8 *)buf) + read_total, len - read_total); + if (len_read <= 0) { return 0; } read_total += len_read; } diff --git a/test/test.sh b/test/test.sh index 7f1410ea..431e3983 100755 --- a/test/test.sh +++ b/test/test.sh @@ -115,7 +115,7 @@ $ECHO "${RESET}${GREY}[*] starting afl++ test framework ..." test -z "$SYS" && $ECHO "$YELLOW[-] uname -m did not succeed" $ECHO "$BLUE[*] Testing: ${AFL_GCC}, afl-showmap, afl-fuzz, afl-cmin and afl-tmin" -test "$SYS" = "i686" -o "$SYS" = "x86_64" -o "$SYS" = "amd64" -o "$SYS" = "i86pc" && { +test "$SYS" = "i686" -o "$SYS" = "x86_64" -o "$SYS" = "amd64" -o "$SYS" = "i86pc" -o "$SYS" = "i386" && { test -e ../${AFL_GCC} -a -e ../afl-showmap -a -e ../afl-fuzz && { ../${AFL_GCC} -o test-instr.plain ../test-instr.c > /dev/null 2>&1 AFL_HARDEN=1 ../${AFL_GCC} -o test-compcov.harden test-compcov.c > /dev/null 2>&1 |