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 | 6ba93205b0efeffaf73f55624bb920bd31c02eab (patch) | |
tree | a8476bc3c692917781030da40f6bd7b7f9fe76cc /net/server_epoll.lua | |
parent | e9146e877738a270fb8119baef6a6f3b81d33e6c (diff) | |
download | prosody-6ba93205b0efeffaf73f55624bb920bd31c02eab.tar.gz prosody-6ba93205b0efeffaf73f55624bb920bd31c02eab.zip |
net.server_epoll: Protect from errors in get{peer,sock}name
Diffstat (limited to 'net/server_epoll.lua')
-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 |