Mercurial > prosody-hg
diff util-src/poll.c @ 14213:75d09be04f13 13.0
util.poll: Reject file descriptors outside of FD_SETSIZE in all methods
To prevent accesses outside the bounds of the FD sets.
Previously only checked on the write, but maybe this could potentially
cause weird behavior as well?
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 31 May 2026 11:51:22 +0200 |
| parents | a331cde41c85 |
| children |
line wrap: on
line diff
--- a/util-src/poll.c Sat May 30 19:21:08 2026 +0200 +++ b/util-src/poll.c Sun May 31 11:51:22 2026 +0200 @@ -234,6 +234,13 @@ #endif #ifdef USE_SELECT + if(fd >= FD_SETSIZE) { + luaL_pushfail(L); + lua_pushstring(L, strerror(EBADF)); + lua_pushinteger(L, EBADF); + return 3; + } + if(!FD_ISSET(fd, &state->all)) { luaL_pushfail(L); lua_pushstring(L, strerror(ENOENT)); @@ -327,6 +334,13 @@ #endif #ifdef USE_SELECT + if(fd >= FD_SETSIZE) { + luaL_pushfail(L); + lua_pushstring(L, strerror(EBADF)); + lua_pushinteger(L, EBADF); + return 3; + } + if(!FD_ISSET(fd, &state->all)) { luaL_pushfail(L); lua_pushstring(L, strerror(ENOENT));
