moonbridge

changeset 138:2097b1835d96

Check if file descriptors are in valid range before using them for select
author jbe
date Fri Apr 17 19:20:23 2015 +0200 (2015-04-17)
parents 46ebdc5bf825
children f148bd2b3d05
files moonbridge_io.c
line diff
     1.1 --- a/moonbridge_io.c	Thu Apr 16 22:20:33 2015 +0200
     1.2 +++ b/moonbridge_io.c	Fri Apr 17 19:20:23 2015 +0200
     1.3 @@ -1043,6 +1043,7 @@
     1.4              if (!isnum) luaL_error(L, "Expected integer (file descriptor), I/O handle, or listener in table key");
     1.5            }
     1.6          }
     1.7 +        if (fd < 0 || fd >= FD_SETSIZE) luaL_error(L, "File descriptor out of valid range");
     1.8          FD_SET(fd, &readfds);
     1.9          if (fd+1 > nfds) nfds = fd+1;
    1.10        }
    1.11 @@ -1063,6 +1064,7 @@
    1.12            fd = lua_tointegerx(L, -2, &isnum);
    1.13            if (!isnum) luaL_error(L, "Expected integer (file descriptor) or I/O handle in table key");
    1.14          }
    1.15 +        if (fd < 0 || fd >= FD_SETSIZE) luaL_error(L, "File descriptor out of valid range");
    1.16          FD_SET(fd, &writefds);
    1.17          if (fd+1 > nfds) nfds = fd+1;
    1.18        }

Impressum / About Us