Skip to content

Commit b73aa11

Browse files
committed
[FIX] socket timeout over 1s
1 parent 36a4103 commit b73aa11

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

afl-fuzz.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1080,8 +1080,8 @@ int send_over_network()
10801080
//Set timeout for socket data sending/receiving -- otherwise it causes a big delay
10811081
//if the server is still alive after processing all the requests
10821082
struct timeval timeout;
1083-
timeout.tv_sec = 0;
1084-
timeout.tv_usec = socket_timeout_usecs;
1083+
timeout.tv_sec = socket_timeout_usecs / 1000000;
1084+
timeout.tv_usec = socket_timeout_usecs % 1000000;
10851085
setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof(timeout));
10861086

10871087
memset(&serv_addr, '0', sizeof(serv_addr));

afl-replay.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ int main(int argc, char* argv[])
9090
//if the server is still alive after processing all the requests
9191
struct timeval timeout;
9292

93-
timeout.tv_sec = 0;
94-
timeout.tv_usec = socket_timeout;
93+
timeout.tv_sec = socket_timeout / 1000000;
94+
timeout.tv_usec = socket_timeout % 1000000;
9595

9696
setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof(timeout));
9797

aflnet-replay.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ int main(int argc, char* argv[])
8282
//if the server is still alive after processing all the requests
8383
struct timeval timeout;
8484

85-
timeout.tv_sec = 0;
86-
timeout.tv_usec = socket_timeout;
85+
timeout.tv_sec = socket_timeout / 1000000;
86+
timeout.tv_usec = socket_timeout % 1000000;
8787

8888
setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof(timeout));
8989

0 commit comments

Comments
 (0)