diff options
author | daurnimator <quae@daurnimator.com> | 2013-12-18 17:51:27 -0500 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2013-12-18 17:51:27 -0500 |
commit | 60447003358dfd3d615886219b3672f678d95ecd (patch) | |
tree | f75fcd59e2a6a87ca23c2473925ca2caf15cd2a6 /net | |
parent | 388fa0cd28e4a9911f6d6504e15126071952a453 (diff) | |
download | prosody-60447003358dfd3d615886219b3672f678d95ecd.tar.gz prosody-60447003358dfd3d615886219b3672f678d95ecd.zip |
net/server_select: Check arguments to add_server correctly
Diffstat (limited to 'net')
-rw-r--r-- | net/server_select.lua | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/net/server_select.lua b/net/server_select.lua index 322c0b57..62c889e9 100644 --- a/net/server_select.lua +++ b/net/server_select.lua @@ -723,11 +723,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" @@ -738,7 +740,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 ) |