cshutdn: acknowledge FD_SETSIZE for shutdown descriptors

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
This commit is contained in:
Stanislav Fort 2025-11-10 08:18:53 +01:00 committed by Daniel Stenberg
parent 00872d5c98
commit b0aba1005b
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View 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);