qpoll: disallow file descriptors bigger than FD_SETSIZE

I don't know which platforms qpoll.cpp is still used and if in those
there's even a way to increase the file descriptor limit above
FD_SETSIZE's. But this is an easy change and protects against buffer
overruns.

Change-Id: I810d70e579eb4e2c8e45fffd1718ca1aac8e6bef
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 8c1776ee0781b49e0966d8394f02f55a90d73eba)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Thiago Macieira 2022-09-27 11:11:18 -07:00 committed by Qt Cherry-pick Bot
parent 1906d225f9
commit ff8beb27a5

View File

@ -156,6 +156,11 @@ int qt_poll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout_ts)
if (fds[i].fd < 0)
continue;
if (fds[i].fd > FD_SETSIZE) {
errno = EINVAL;
return -1;
}
if (fds[i].events & QT_POLL_EVENTS_MASK)
continue;