aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2013-12-18 17:51:27 -0500
committerdaurnimator <quae@daurnimator.com>2013-12-18 17:51:27 -0500
commit1bdf48e7d2bb8cc29d9b2d11c004a4b7e6f82515 (patch)
tree8caac7230b9d424b70d50fb9f2e7f5cd4e224323 /net
parenta3c709b756f0789a33a1bc3703504b29981d2623 (diff)
downloadprosody-1bdf48e7d2bb8cc29d9b2d11c004a4b7e6f82515.tar.gz
prosody-1bdf48e7d2bb8cc29d9b2d11c004a4b7e6f82515.zip
net/server_select: Check arguments to add_server correctly
Diffstat (limited to 'net')
-rw-r--r--net/server_select.lua7
1 files changed, 4 insertions, 3 deletions
diff --git a/net/server_select.lua b/net/server_select.lua
index 61078202..e319e016 100644
--- a/net/server_select.lua
+++ b/net/server_select.lua
@@ -713,11 +713,13 @@ end
----------------------------------// PUBLIC //--
addserver = function( addr, port, listeners, pattern, sslctx ) -- this function provides a way for other scripts to reg a server
+ addr = addr or "*"
local err
if type( listeners ) ~= "table" then
err = "invalid listener table"
- end
- if type( port ) ~= "number" or not ( port >= 0 and port <= 65535 ) then
+ elseif type ( addr ) ~= "string" then
+ err = "invalid address"
+ elseif type( port ) ~= "number" or not ( port >= 0 and port <= 65535 ) then
err = "invalid port"
elseif _server[ addr..":"..port ] then
err = "listeners on '[" .. addr .. "]:" .. port .. "' already exist"
@@ -728,7 +730,6 @@ addserver = function( addr, port, listeners, pattern, sslctx ) -- this function
out_error( "server.lua, [", addr, "]:", port, ": ", err )
return nil, err
end
- addr = addr or "*"
local server, err = socket_bind( addr, port, _tcpbacklog )
if err then
out_error( "server.lua, [", addr, "]:", port, ": ", err )