From: Gleb Smirnoff Date: Fri, 23 Jan 2026 18:44:23 +0000 (-0800) Subject: SSL_sendfile: make it more like bio/bss_sock.c:sock_write() X-Git-Tag: openssl-4.0.0-alpha1~282 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e003d87f8abdee57e8f26de7d89358b808b73989;p=thirdparty%2Fopenssl.git SSL_sendfile: make it more like bio/bss_sock.c:sock_write() First, use BIO_sock_should_retry(). Second, clear BIO retry flags. Otherwise after an SSL_sendfile that failed, no matter how many succeded after, the flags would still be up. Fixes: #29742 Reviewed-by: Neil Horman Reviewed-by: Paul Dale MergeDate: Wed Feb 18 23:31:24 2026 (Merged from https://github.com/openssl/openssl/pull/29744) --- diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index e30c3bba17a..352f58911cb 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -2705,13 +2705,12 @@ ossl_ssize_t SSL_sendfile(SSL *s, int fd, off_t offset, size_t size, int flags) return -1; #else ret = ktls_sendfile(SSL_get_wfd(s), fd, offset, size, &sbytes, flags); + BIO_clear_retry_flags(sc->wbio); if (ret < 0) { -#if defined(EAGAIN) && defined(EINTR) && defined(EBUSY) - if ((get_last_sys_error() == EAGAIN) || (get_last_sys_error() == EINTR) || (get_last_sys_error() == EBUSY)) { + if (BIO_sock_should_retry(ret)) { BIO_set_retry_write(sc->wbio); return (sbytes > 0 ? sbytes : ret); } else -#endif ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(), "ktls_sendfile failure"); return ret;