Skip to content

Commit

Permalink
TLSServer: Fix crash on logging errors
Browse files Browse the repository at this point in the history
In #3330 we added host name information to the error messages but it
doesn't care the case when it fails getpeername(2).

Signed-off-by: Takuro Ashie <[email protected]>
  • Loading branch information
ashie committed Aug 5, 2021
1 parent b28f7d7 commit 5b71d51
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/fluent/plugin_helper/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -709,13 +709,15 @@ def try_tls_accept
return true
end
rescue Errno::EPIPE, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH => e
peeraddr = (@_handler_socket.peeraddr rescue PEERADDR_FAILED)
@log.trace "unexpected error before accepting TLS connection",
host: @_handler_socket.peeraddr[3], port: @_handler_socket.peeraddr[1], error: e
addr: peeraddr[3], host: peeraddr[2], port: peeraddr[1], error: e
close rescue nil
rescue OpenSSL::SSL::SSLError => e
peeraddr = (@_handler_socket.peeraddr rescue PEERADDR_FAILED)
# Use same log level as on_readable
@log.warn "unexpected error before accepting TLS connection by OpenSSL",
host: @_handler_socket.peeraddr[3], port: @_handler_socket.peeraddr[1], error: e
addr: peeraddr[3], host: peeraddr[2], port: peeraddr[1], error: e
close rescue nil
end

Expand Down

0 comments on commit 5b71d51

Please sign in to comment.