Skip to content

Commit

Permalink
openssl: use strerror on SSL_ERROR_SYSCALL
Browse files Browse the repository at this point in the history
Instead of showing the somewhat nonsensical errno number, use strerror()
to provide a more relatable error message.

Closes #4411
  • Loading branch information
bagder committed Sep 26, 2019
1 parent 2078e77 commit 0ab38f5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/vtls/openssl.c
Expand Up @@ -44,6 +44,7 @@
#include "strcase.h"
#include "hostcheck.h"
#include "multiif.h"
#include "strerror.h"
#include "curl_printf.h"
#include <openssl/ssl.h>
#include <openssl/rand.h>
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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" */
Expand Down

0 comments on commit 0ab38f5

Please sign in to comment.