From: Daniel Stenberg Date: Tue, 24 Sep 2019 12:03:23 +0000 (+0200) Subject: openssl: use strerror on SSL_ERROR_SYSCALL X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ab38f5fd6c15451cdec816ca6c6a163b98e1d25;p=curl openssl: use strerror on SSL_ERROR_SYSCALL Instead of showing the somewhat nonsensical errno number, use strerror() to provide a more relatable error message. Closes #4411 --- diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index 28d23c50f..760758d23 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -44,6 +44,7 @@ #include "strcase.h" #include "hostcheck.h" #include "multiif.h" +#include "strerror.h" #include "curl_printf.h" #include #include @@ -3825,8 +3826,8 @@ static ssize_t ossl_send(struct connectdata *conn, *curlcode = CURLE_AGAIN; return -1; case SSL_ERROR_SYSCALL: - failf(conn->data, "SSL_write() returned SYSCALL, errno = %d", - SOCKERRNO); + Curl_strerror(SOCKERRNO, error_buffer, sizeof(error_buffer)); + failf(conn->data, OSSL_PACKAGE " SSL_write: %s", error_buffer); *curlcode = CURLE_SEND_ERROR; return -1; case SSL_ERROR_SSL: @@ -3893,6 +3894,11 @@ static ssize_t ossl_recv(struct connectdata *conn, /* connection data */ /* there's data pending, re-invoke SSL_read() */ *curlcode = CURLE_AGAIN; return -1; + case SSL_ERROR_SYSCALL: + Curl_strerror(SOCKERRNO, error_buffer, sizeof(error_buffer)); + failf(conn->data, OSSL_PACKAGE " SSL_read: %s", error_buffer); + *curlcode = CURLE_RECV_ERROR; + return -1; default: /* openssl/ssl.h for SSL_ERROR_SYSCALL says "look at error stack/return value/errno" */