From: Marc Hoersken Date: Sun, 2 May 2021 18:44:35 +0000 (+0200) Subject: sockfilt: fix invalid increment of handles index variable nfd X-Git-Tag: curl-7_77_0~86 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d698c704211ae227a35188c9c80414e650b8c4fc;p=thirdparty%2Fcurl.git sockfilt: fix invalid increment of handles index variable nfd Only increment the array index if we actually stored a handle. Follow up to e917492048f4b85a0fd58a033d10072fc7666c3b Closes #6992 --- diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c index 7009b2585b..d109d69c94 100644 --- a/tests/server/sockfilt.c +++ b/tests/server/sockfilt.c @@ -725,6 +725,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds, handles[nfd] = signal; data[nth].signal = signal; data[nth].thread = handle; + nfd++; nth++; } else { @@ -734,9 +735,11 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds, } else if(fd == fileno(stdout)) { handles[nfd] = GetStdHandle(STD_OUTPUT_HANDLE); + nfd++; } else if(fd == fileno(stderr)) { handles[nfd] = GetStdHandle(STD_ERROR_HANDLE); + nfd++; } else { wsaevent = WSACreateEvent(); @@ -763,6 +766,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds, if(FD_ISSET(wsasock, &exceptsock)) data[nfd].wsastate |= FD_OOB; } + nfd++; nws++; } else { @@ -775,6 +779,7 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds, handles[nfd] = signal; data[nth].signal = signal; data[nth].thread = handle; + nfd++; nth++; } else { @@ -784,7 +789,6 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds, } } } - nfd++; } }