Software /
code /
prosody
Changeset
9382:31a2be28729c
net.server_epoll: Protect from errors in get{peer,sock}name
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 26 Sep 2018 13:52:10 +0200 |
parents | 9381:80be543a3785 |
children | 9383:3260902a5b22 |
files | net/server_epoll.lua |
diffstat | 1 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/net/server_epoll.lua Mon Sep 24 19:47:53 2018 +0200 +++ b/net/server_epoll.lua Wed Sep 26 13:52:10 2018 +0200 @@ -501,11 +501,13 @@ 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