Diff

net/server_select.lua @ 5960:2a6edd4678c5

net/server_select: addclient: Check arguments
author daurnimator <quae@daurnimator.com>
date Wed, 18 Dec 2013 17:55:03 -0500
parent 5959:9e3b15199ec5
child 5961:5745bb2b6890
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
@@ -931,6 +931,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