From: Steffan Karger <steffan.kar...@fox-it.com>

Instead of logging the fact that an error occured, log the error code and
description (when available in the PolarSSL build).

Signed-off-by: Joachim Schipper <joachim.schip...@fox-it.com>
---
 src/openvpn/ssl_polarssl.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/openvpn/ssl_polarssl.c b/src/openvpn/ssl_polarssl.c
index 4d00ad6..c787374 100644
--- a/src/openvpn/ssl_polarssl.c
+++ b/src/openvpn/ssl_polarssl.c
@@ -643,6 +643,7 @@ key_state_read_ciphertext (struct key_state_ssl *ks, struct 
buffer *buf,
 {
   int retval = 0;
   int len = 0;
+  char error_message[1024];

   perf_push (PERF_BIO_READ_CIPHERTEXT);

@@ -668,7 +669,8 @@ key_state_read_ciphertext (struct key_state_ssl *ks, struct 
buffer *buf,
       perf_pop ();
       if (POLARSSL_ERR_NET_WANT_WRITE == retval || POLARSSL_ERR_NET_WANT_READ 
== retval)
        return 0;
-      msg (D_TLS_ERRORS, "TLS_ERROR: read tls_read_plaintext error");
+      error_strerror(retval, error_message, sizeof(error_message));
+      msg (D_TLS_ERRORS, "TLS_ERROR: read tls_read_ciphertext error: %d %s", 
retval, error_message);
       buf->len = 0;
       return -1;
     }
@@ -740,6 +742,7 @@ key_state_read_plaintext (struct key_state_ssl *ks, struct 
buffer *buf,
 {
   int retval = 0;
   int len = 0;
+  char error_message[1024];

   perf_push (PERF_BIO_READ_PLAINTEXT);

@@ -764,7 +767,8 @@ key_state_read_plaintext (struct key_state_ssl *ks, struct 
buffer *buf,
     {
       if (POLARSSL_ERR_NET_WANT_WRITE == retval || POLARSSL_ERR_NET_WANT_READ 
== retval)
        return 0;
-      msg (D_TLS_ERRORS, "TLS_ERROR: read tls_read_plaintext error");
+      error_strerror(retval, error_message, sizeof(error_message));
+      msg (D_TLS_ERRORS, "TLS_ERROR: read tls_read_plaintext error: %d %s", 
retval, error_message);
       buf->len = 0;
       perf_pop ();
       return -1;
-- 
1.7.9.5


Reply via email to