From: Artem Boldariev Date: Thu, 14 Jul 2022 20:33:26 +0000 (+0300) Subject: TLS: clear 'errno' when handling SSL status X-Git-Tag: v9.19.4~9^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5d450cd0baf3f3f8149cbb96d303bfc51995aa65;p=thirdparty%2Fbind9.git TLS: clear 'errno' when handling SSL status Sometimes tls_do_bio() might be called when there is no new data to process (most notably, when resuming reads), in such a case internal TLS session state will remain untouched and old value in 'errno' will alter the result of SSL_get_error() call, possibly making it to return SSL_ERROR_SYSCALL. This value will be treated as an error, and will lead to closing the connection, which is not what expected. --- diff --git a/lib/isc/netmgr/tlsstream.c b/lib/isc/netmgr/tlsstream.c index 169b3910028..13789cd86a9 100644 --- a/lib/isc/netmgr/tlsstream.c +++ b/lib/isc/netmgr/tlsstream.c @@ -496,6 +496,7 @@ tls_do_bio(isc_nmsocket_t *sock, isc_region_t *received_data, } } } + errno = 0; tls_status = SSL_get_error(sock->tlsstream.tls, rv); saved_errno = errno;