]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cshutdn: acknowledge FD_SETSIZE for shutdown descriptors
authorStanislav Fort <stanislav.fort@aisle.com>
Mon, 10 Nov 2025 07:18:53 +0000 (08:18 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 10 Nov 2025 07:54:43 +0000 (08:54 +0100)
In the logic called for curl_multi_fdset().

File descriptors larger than FD_SETSIZE size are simply ignored, which
of course will make things break but at least it does not trash memory.

Reported-by: Stanislav Fort (Aisle Research)
Closes #19439

lib/cshutdn.c

index c2788e7780a4841d014e87957ce60326c916fd90..1ce34606ecf30dcf8d9ae24153fcd2f46b49062a 100644 (file)
@@ -503,20 +503,23 @@ void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
         continue;
 
       for(i = 0; i < ps.n; i++) {
+        curl_socket_t sock = ps.sockets[i];
+        if(!FDSET_SOCK(sock))
+          continue;
 #ifdef __DJGPP__
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Warith-conversion"
 #endif
         if(ps.actions[i] & CURL_POLL_IN)
-          FD_SET(ps.sockets[i], read_fd_set);
+          FD_SET(sock, read_fd_set);
         if(ps.actions[i] & CURL_POLL_OUT)
-          FD_SET(ps.sockets[i], write_fd_set);
+          FD_SET(sock, write_fd_set);
 #ifdef __DJGPP__
 #pragma GCC diagnostic pop
 #endif
         if((ps.actions[i] & (CURL_POLL_OUT | CURL_POLL_IN)) &&
-           ((int)ps.sockets[i] > *maxfd))
-          *maxfd = (int)ps.sockets[i];
+           ((int)sock > *maxfd))
+          *maxfd = (int)sock;
       }
     }
     Curl_pollset_cleanup(&ps);