Skip to content

Conversation

@rhenium
Copy link
Member

@rhenium rhenium commented Dec 7, 2025

The errno reported in OpenSSL::SSL::SSLError message sometimes does not match what SSL_accept()/SSL_connect() actually encountered. Depending on the evaluation order of function arguments to ossl_raise(), it can be overwritten by peeraddr_ip_str().

Save errno into a local variable immediately after the OpenSSL function returns, and avoid touching the thread-local errno afterward.

Also, expand rb_sys_fail() and rb_io_maybe_wait_{readable,writable}() so that they do not rely on errno.

@rhenium rhenium force-pushed the ky/ssl-errors-peeraddr-errno branch from 3d32739 to 1f128c3 Compare December 7, 2025 17:12
The errno reported in OpenSSL::SSL::SSLError message sometimes does not
match what SSL_accept()/SSL_connect() actually encountered. Depending
on the evaluation order of function arguments to ossl_raise(), it can
be overwritten by peeraddr_ip_str().

Save errno into a local variable immediately after the OpenSSL function
returns, and avoid touching the thread-local errno afterward.

Also, expand rb_sys_fail() and rb_io_{maybe_,}wait_{read,writ}able()
so that they do not rely on errno.
Remove an unnecessary instance variable lookup and constant lookup.
@rhenium rhenium force-pushed the ky/ssl-errors-peeraddr-errno branch from 1f128c3 to 74d6b09 Compare December 7, 2025 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant