From 712c0942939c9aba2f2afadb9e4276b1a3df1345 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Fri, 23 Aug 2019 13:56:09 -0700 Subject: Simplify NO_KTLS path in SSL_sendfile. Avoid tripping over errno values from previous system calls in the thread and just hardcode the specific error. BIO_get_ktls_send() should never be true in the NO_KTLS path, so the #ifdef could be moved even higher up to assume that error path in the NO_KTLS case instead. Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/10045) --- ssl/ssl_lib.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'ssl') diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 794af76530..61c90218e3 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -2061,11 +2061,11 @@ ossl_ssize_t SSL_sendfile(SSL *s, int fd, off_t offset, size_t size, int flags) return -1; } -#ifndef OPENSSL_NO_KTLS - ret = ktls_sendfile(SSL_get_wfd(s), fd, offset, size, flags); +#ifdef OPENSSL_NO_KTLS + ERR_raise_data(ERR_LIB_SYS, ERR_R_INTERNAL_ERROR, "calling sendfile()"); + return -1; #else - ret = -1; -#endif + ret = ktls_sendfile(SSL_get_wfd(s), fd, offset, size, flags); if (ret < 0) { #if defined(EAGAIN) && defined(EINTR) && defined(EBUSY) if ((get_last_sys_error() == EAGAIN) || @@ -2074,16 +2074,12 @@ ossl_ssize_t SSL_sendfile(SSL *s, int fd, off_t offset, size_t size, int flags) BIO_set_retry_write(s->wbio); else #endif -#ifdef OPENSSL_NO_KTLS - ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(), - "calling sendfile()"); -#else SSLerr(SSL_F_SSL_SENDFILE, SSL_R_UNINITIALIZED); -#endif return ret; } s->rwstate = SSL_NOTHING; return ret; +#endif } int SSL_write(SSL *s, const void *buf, int num) -- cgit v1.2.3