diff options
author | Kim Alvefur <zash@zash.se> | 2018-09-26 13:52:10 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-09-26 13:52:10 +0200 |
commit | 4691dc6bef42c073b17c4581c59ada803f57a7f7 (patch) | |
tree | a8476bc3c692917781030da40f6bd7b7f9fe76cc | |
parent | f1ce7fec6655649f90ca73387b28cff548c3d800 (diff) | |
download | prosody-4691dc6bef42c073b17c4581c59ada803f57a7f7.tar.gz prosody-4691dc6bef42c073b17c4581c59ada803f57a7f7.zip |
net.server_epoll: Protect from errors in get{peer,sock}name
-rw-r--r-- | net/server_epoll.lua | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua index 0a389d8a..cd91fce0 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -501,11 +501,13 @@ local function wrapsocket(client, server, read_size, listeners, tls_ctx) -- luas tls_ctx = tls_ctx; }, interface_mt); - if client.getpeername then - conn.peername, conn.peerport = client:getpeername(); + local ok, peername, peerport = pcall(client.getpeername, client); + if ok then + conn.peername, conn.peerport = peername, peerport; end - if client.getsockname then - conn.sockname, conn.sockport = client:getsockname(); + local ok, sockname, sockport = pcall(client.getsockname, client); + if ok then + conn.sockname, conn.sockport = sockname, sockport; end return conn; end |