comparison 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
comparison
equal deleted inserted replaced
14209:c4aa9b2b4787 14213:75d09be04f13
232 lua_pushinteger(L, ENOENT); 232 lua_pushinteger(L, ENOENT);
233 return 3; 233 return 3;
234 #endif 234 #endif
235 #ifdef USE_SELECT 235 #ifdef USE_SELECT
236 236
237 if(fd >= FD_SETSIZE) {
238 luaL_pushfail(L);
239 lua_pushstring(L, strerror(EBADF));
240 lua_pushinteger(L, EBADF);
241 return 3;
242 }
243
237 if(!FD_ISSET(fd, &state->all)) { 244 if(!FD_ISSET(fd, &state->all)) {
238 luaL_pushfail(L); 245 luaL_pushfail(L);
239 lua_pushstring(L, strerror(ENOENT)); 246 lua_pushstring(L, strerror(ENOENT));
240 lua_pushinteger(L, ENOENT); 247 lua_pushinteger(L, ENOENT);
241 return 3; 248 return 3;
324 lua_pushstring(L, strerror(ENOENT)); 331 lua_pushstring(L, strerror(ENOENT));
325 lua_pushinteger(L, ENOENT); 332 lua_pushinteger(L, ENOENT);
326 return 3; 333 return 3;
327 #endif 334 #endif
328 #ifdef USE_SELECT 335 #ifdef USE_SELECT
336
337 if(fd >= FD_SETSIZE) {
338 luaL_pushfail(L);
339 lua_pushstring(L, strerror(EBADF));
340 lua_pushinteger(L, EBADF);
341 return 3;
342 }
329 343
330 if(!FD_ISSET(fd, &state->all)) { 344 if(!FD_ISSET(fd, &state->all)) {
331 luaL_pushfail(L); 345 luaL_pushfail(L);
332 lua_pushstring(L, strerror(ENOENT)); 346 lua_pushstring(L, strerror(ENOENT));
333 lua_pushinteger(L, ENOENT); 347 lua_pushinteger(L, ENOENT);