From 4691dc6bef42c073b17c4581c59ada803f57a7f7 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 26 Sep 2018 13:52:10 +0200 Subject: net.server_epoll: Protect from errors in get{peer,sock}name --- net/server_epoll.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'net') 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 -- cgit v1.2.3