]> git.sesse.net Git - vlc/commitdiff
Avoid overflows in the LUA net API. Run-time behavior will still be incorrect however.
authorRémi Denis-Courmont <rem@videolan.org>
Fri, 18 Jan 2008 17:32:38 +0000 (17:32 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Fri, 18 Jan 2008 17:32:38 +0000 (17:32 +0000)
modules/misc/lua/net.c

index 607fdae11973b92b2a381c8e7b4aac5ee414fbe0..c26f82744a0fe9a600113b2f015d8c45b13b6fab 100644 (file)
@@ -135,6 +135,9 @@ int vlclua_net_select( lua_State *L )
     fd_set *fds_write = (fd_set*)luaL_checkuserdata( L, 3, sizeof( fd_set ) );
     double f_timeout = luaL_checknumber( L, 4 );
     struct timeval timeout;
+
+    if( i_nfds > FD_SETSIZE )
+        i_nfds = FD_SETSIZE;
     timeout.tv_sec = (int)f_timeout;
     timeout.tv_usec = (int)(1e6*(f_timeout-(double)((int)f_timeout)));
     i_ret = select( i_nfds, fds_read, fds_write, 0, &timeout );
@@ -168,7 +171,12 @@ int vlclua_fd_set( lua_State *L )
 {
     fd_set *fds = (fd_set*)luaL_checkuserdata( L, 1, sizeof( fd_set ) );
     int i_fd = luaL_checkint( L, 2 );
-    FD_SET( i_fd, fds );
+    /* FIXME: we should really use poll() instead here, but that breaks the
+     * VLC/LUA API*/
+#ifndef WIN32
+    if( i_fd < FD_SETSIZE )
+#endif
+        FD_SET( i_fd, fds );
     return 0;
 }
 int vlclua_fd_zero( lua_State *L )