noxxi / p5-io-socket-ssl

IO::Socket::SSL Perl Module
36 stars 60 forks source link

The ossl_trace debug function may corrupt the value of $! (heisenbug) #143

Closed Yaribz closed 1 year ago

Yaribz commented 1 year ago

The value of $! is used in IO::Socket::SSL workflows to detect some error cases after I/O SSL operations. For example, in the _generic_read function the value of $! is used to distinguish between SSL EOF and more severe SSL errors.

The ossl_trace debug function is called automatically by the set_msg_callback system of OpenSSL before other perl code has a chance to check the value of $!. Unfortunately, this function is likely to corrupt the value of $! due to the call to Net::SSLeay::SSL_alert_desc_string_long (which sets $! to ENOENT when not found). This can lead to annoying heisenbugs...