mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-15 19:38:09 +00:00
Merge pull request #383 from dgmelski/fix-read-timed
Fix read_timed when accumulating short reads
This commit is contained in:
@ -101,7 +101,7 @@ endif
|
|||||||
|
|
||||||
ifeq "$(shell uname -s)" "OpenBSD"
|
ifeq "$(shell uname -s)" "OpenBSD"
|
||||||
override CFLAGS += -I /usr/local/include/
|
override CFLAGS += -I /usr/local/include/
|
||||||
LDFLAGS += -L /usr/local/lib/
|
LDFLAGS += -Wl,-z,notext -L /usr/local/lib/
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq "$(shell uname -s)" "NetBSD"
|
ifeq "$(shell uname -s)" "NetBSD"
|
||||||
|
@ -885,9 +885,9 @@ u32 read_timed(s32 fd, void *buf, size_t len, u32 timeout_ms,
|
|||||||
timeout.tv_usec = (timeout_ms % 1000) * 1000;
|
timeout.tv_usec = (timeout_ms % 1000) * 1000;
|
||||||
|
|
||||||
size_t read_total = 0;
|
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. */
|
/* set exceptfds as well to return when a child exited/closed the pipe. */
|
||||||
int sret = select(fd + 1, &readfds, NULL, NULL, &timeout);
|
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);
|
len_read = read(fd, ((u8 *)buf) + read_total, len - read_total);
|
||||||
if (!len_read) { return 0; }
|
if (len_read <= 0) { return 0; }
|
||||||
read_total += len_read;
|
read_total += len_read;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ $ECHO "${RESET}${GREY}[*] starting afl++ test framework ..."
|
|||||||
test -z "$SYS" && $ECHO "$YELLOW[-] uname -m did not succeed"
|
test -z "$SYS" && $ECHO "$YELLOW[-] uname -m did not succeed"
|
||||||
|
|
||||||
$ECHO "$BLUE[*] Testing: ${AFL_GCC}, afl-showmap, afl-fuzz, afl-cmin and afl-tmin"
|
$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 && {
|
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_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
|
AFL_HARDEN=1 ../${AFL_GCC} -o test-compcov.harden test-compcov.c > /dev/null 2>&1
|
||||||
|
Reference in New Issue
Block a user