Software /
code /
prosody
Changeset
6812:7af63377a1cf
net/server_select: Check arguments to add_server correctly
author | daurnimator <quae@daurnimator.com> |
---|---|
date | Wed, 18 Dec 2013 17:51:27 -0500 |
parents | 6810:533fd843d91f |
children | 6813:b1615fa62e59 |
files | net/server_select.lua |
diffstat | 1 files changed, 4 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/net/server_select.lua Wed Sep 02 18:54:34 2015 +0100 +++ b/net/server_select.lua Wed Dec 18 17:51:27 2013 -0500 @@ -723,11 +723,13 @@ ----------------------------------// 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 @@ 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 )