diff options
author | daurnimator <quae@daurnimator.com> | 2013-12-18 17:55:03 -0500 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2013-12-18 17:55:03 -0500 |
commit | ca6af8e2cfeb2373224dc5949f1a3e02cd42b81b (patch) | |
tree | d3befe7e319702fdbe50c781afa330993a9daba4 | |
parent | 32b5b56170e51bf48bbd1467a84f2134f86e4cdd (diff) | |
download | prosody-ca6af8e2cfeb2373224dc5949f1a3e02cd42b81b.tar.gz prosody-ca6af8e2cfeb2373224dc5949f1a3e02cd42b81b.zip |
net/server_select: addclient: Check arguments
-rw-r--r-- | net/server_select.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/net/server_select.lua b/net/server_select.lua index bd4e59df..c707e48f 100644 --- a/net/server_select.lua +++ b/net/server_select.lua @@ -931,6 +931,21 @@ local wrapclient = function( socket, ip, serverport, listeners, pattern, sslctx 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 |