From 49d173f4e4c05bbc9e6f256f8914979dad85e9d3 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sun, 6 Sep 2020 12:15:10 +0100 Subject: [PATCH 38/42] GnuTLS: clear errno before any data i/o op, so error logging does not see stale values (cherry picked from commit d52a8ce8499fbb88f4670623df9f52d3e790292b) --- src/tls-gnu.c | 3 +++ diff --git src/tls-gnu.c src/tls-gnu.c index dafe1be0c..6ee603595 100644 --- src/tls-gnu.c +++ src/tls-gnu.c @@ -3162,6 +3162,7 @@ DEBUG(D_tls) debug_printf("Calling gnutls_record_recv(session=%p, buffer=%p, buf sigalrm_seen = FALSE; if (smtp_receive_timeout > 0) ALARM(smtp_receive_timeout); +errno = 0; do inbytes = gnutls_record_recv(state->session, state->xfer_buffer, MIN(ssl_xfer_buffer_size, lim)); @@ -3322,6 +3323,7 @@ DEBUG(D_tls) debug_printf("Calling gnutls_record_recv(session=%p, buffer=%p, len=" SIZE_T_FMT ")\n", state->session, buff, len); +errno = 0; do inbytes = gnutls_record_recv(state->session, buff, len); while (inbytes == GNUTLS_E_AGAIN); @@ -3385,6 +3387,7 @@ while (left > 0) DEBUG(D_tls) debug_printf("gnutls_record_send(session=%p, buffer=%p, left=" SIZE_T_FMT ")\n", state->session, buff, left); + errno = 0; do outbytes = gnutls_record_send(state->session, buff, left); while (outbytes == GNUTLS_E_AGAIN); -- 2.29.2