]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
sockfilt: fix invalid increment of handles index variable nfd
authorMarc Hoersken <info@marc-hoersken.de>
Sun, 2 May 2021 18:44:35 +0000 (20:44 +0200)
committerMarc Hoersken <info@marc-hoersken.de>
Wed, 5 May 2021 20:30:48 +0000 (22:30 +0200)
Only increment the array index if we actually stored a handle.

Follow up to e917492048f4b85a0fd58a033d10072fc7666c3b
Closes #6992

tests/server/sockfilt.c

index 7009b2585bfd5dabeb1fba8cacbd937a50476c06..d109d69c94b83bae3b53659e4cb873f9f9c625c1 100644 (file)
@@ -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++;
     }
   }