diff options
author | Hugo Landau <hlandau@openssl.org> | 2022-03-01 16:47:03 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2022-03-03 13:57:03 +0000 |
commit | b0901f6d7b5ae8a7110afa25bdbb39834a2a1276 (patch) | |
tree | f2b020c2fb5aa3966e743b69ba47f8eb7bc1212d | |
parent | 2e8be29cad5811c85a7c2844198ba1e824f1314c (diff) |
s_server: Do not use SSL_sendfile when KTLS is not being used
Fix a bug in `openssl s_server -WWW` where it would attempt to invoke
`SSL_sendfile` if `-ktls -sendfile` was passed on the command line, even
if KTLS has not actually been enabled, for example because it is not
supported by the host. Since `SSL_sendfile` is only supported when KTLS
is actually being used, this resulted in a failure to serve requests.
Fixes #17503.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17788)
(cherry picked from commit aea68b0ddb7113b982ab503bf830d641e8425759)
-rw-r--r-- | apps/s_server.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/apps/s_server.c b/apps/s_server.c index 5ab58aebfa..acf577180a 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -2992,6 +2992,9 @@ static int www_body(int s, int stype, int prot, unsigned char *context) int total_bytes = 0; #endif int width; +#ifndef OPENSSL_NO_KTLS + int use_sendfile_for_req = use_sendfile; +#endif fd_set readfds; const char *opmode; #ifdef CHARSET_EBCDIC @@ -3329,7 +3332,11 @@ static int www_body(int s, int stype, int prot, unsigned char *context) } /* send the file */ #ifndef OPENSSL_NO_KTLS - if (use_sendfile) { + if (use_sendfile_for_req && !BIO_get_ktls_send(SSL_get_wbio(con))) { + BIO_printf(bio_err, "Warning: sendfile requested but KTLS is not available\n"); + use_sendfile_for_req = 0; + } + if (use_sendfile_for_req) { FILE *fp = NULL; int fd; struct stat st; |