Fuzzing: Keep connecting until successful.

If there is a real problem, the fuzz timeout should be invoked.

Fixes oss-fuzz #55667.

This was a bug in the fuzz target only, not in the code being
fuzzed.
pull/2756/head
Roger A. Light 3 years ago
parent ff8cac9fa7
commit b0a55b60c6

@ -75,16 +75,14 @@ int connect_retrying(int port)
addr.sin_addr.s_addr = inet_addr("127.0.0.1");
sock = socket(AF_INET, SOCK_STREAM, 0);
for(int i=0; i<500; i++){ /* 500x10ms = 5 seconds max wait */
while(1){
errno = 0;
rc = connect(sock, (struct sockaddr *)&addr, sizeof(addr));
if(rc < 0 && errno == ECONNREFUSED){
if(rc < 0){
struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 10000000; /* 10ms */
nanosleep(&ts, NULL);
}else if(rc < 0){
return -1;
}else{
break;
}

Loading…
Cancel
Save