Diff

net/server_select.lua @ 6814:936f969bf783

net/server_select: addclient: Check arguments
author daurnimator <quae@daurnimator.com>
date Wed, 18 Dec 2013 17:55:03 -0500
parent 6813:b1615fa62e59
child 6815:46546d57f639
line wrap: on
line diff
--- a/net/server_select.lua	Wed Dec 18 17:54:31 2013 -0500
+++ b/net/server_select.lua	Wed Dec 18 17:55:03 2013 -0500
@@ -943,6 +943,21 @@
 end
 
 local addclient = function( address, port, listeners, pattern, sslctx )
+	local err
+	if type( listeners ) ~= "table" then
+		err = "invalid listener table"
+	elseif type ( addr ) ~= "string" then
+		err = "invalid address"
+	elseif type( port ) ~= "number" or not ( port >= 0 and port <= 65535 ) then
+		err = "invalid port"
+	elseif sslctx and not has_luasec then
+		err = "luasec not found"
+	end
+	if err then
+		out_error( "server.lua, addclient: ", err )
+		return nil, err
+	end
+
 	local client, err = luasocket.tcp( )
 	if err then
 		return nil, err