From 181777381574173fdc29f873c04cc266037c1cda Mon Sep 17 00:00:00 2001 From: Haroon Ahmed Date: Sun, 6 Oct 2019 14:39:30 +0100 Subject: [PATCH] wip peeraddr raises error --- lib/puma/reactor.rb | 2 +- test/test_puma_server_ssl.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/puma/reactor.rb b/lib/puma/reactor.rb index 50b655038e..c4029bddba 100644 --- a/lib/puma/reactor.rb +++ b/lib/puma/reactor.rb @@ -237,7 +237,7 @@ def run_internal ssl_socket = c.io begin addr = ssl_socket.peeraddr.last - rescue IOError + rescue IOError, Errno::EINVAL addr = "" end diff --git a/test/test_puma_server_ssl.rb b/test/test_puma_server_ssl.rb index 50d4cff3d9..910d1c1574 100644 --- a/test/test_puma_server_ssl.rb +++ b/test/test_puma_server_ssl.rb @@ -199,6 +199,18 @@ def test_tls_v1_1_rejection assert_match(msg, @events.error.message) if @events.error end end + + def test_peeraddr_raises + port = UniquePort.call + + s = TCPServer.new("127.0.0.1", port) + + def s.peeraddr + raise Errno::EINVAL + end + + assert_raises { s.peeraddr } + end end unless DISABLE_SSL # client-side TLS authentication tests