]> granicus.if.org Git - curl/commitdiff
openssl: use strerror on SSL_ERROR_SYSCALL
authorDaniel Stenberg <daniel@haxx.se>
Tue, 24 Sep 2019 12:03:23 +0000 (14:03 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 26 Sep 2019 11:55:18 +0000 (13:55 +0200)
Instead of showing the somewhat nonsensical errno number, use strerror()
to provide a more relatable error message.

Closes #4411

lib/vtls/openssl.c

index 28d23c50fe0e729370939c2ea218914da68fb0d6..760758d234af7c843e6dc1a873ab99788fe068fd 100644 (file)
@@ -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>
@@ -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" */