From 970663f8a1fc8c5f24a3a5da2a2d14267fe4c278 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Thu, 15 Jun 2023 17:42:03 -0500 Subject: [PATCH] in wolfSSL_ERR_reason_error_string(), unconditionally convert positive error codes to negative, and in switch(), match against negated values of OpenSSL positive codes like WOLFSSL_ERROR_WANT_READ. fixes #6514 --- src/internal.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/internal.c b/src/internal.c index 45124fd64..6d8d9592d 100644 --- a/src/internal.c +++ b/src/internal.c @@ -23096,12 +23096,11 @@ const char* wolfSSL_ERR_reason_error_string(unsigned long e) #else int error = (int)e; -#ifdef OPENSSL_EXTRA + /* OpenSSL uses positive error codes */ if (error > 0) { error = -error; } -#endif /* pass to wolfCrypt */ if (error < MAX_CODE_E && error > MIN_CODE_E) { @@ -23200,7 +23199,7 @@ const char* wolfSSL_ERR_reason_error_string(unsigned long e) return "peer ip address mismatch"; case WANT_READ : - case WOLFSSL_ERROR_WANT_READ : + case -WOLFSSL_ERROR_WANT_READ : return "non-blocking socket wants data to be read"; case NOT_READY_ERROR : @@ -23210,9 +23209,22 @@ const char* wolfSSL_ERR_reason_error_string(unsigned long e) return "record layer version error"; case WANT_WRITE : - case WOLFSSL_ERROR_WANT_WRITE : + case -WOLFSSL_ERROR_WANT_WRITE : return "non-blocking socket write buffer full"; + case -WOLFSSL_ERROR_WANT_CONNECT: + case -WOLFSSL_ERROR_WANT_ACCEPT: + return "The underlying BIO was not yet connected"; + + case -WOLFSSL_ERROR_SYSCALL: + return "fatal I/O error in TLS layer"; + + case -WOLFSSL_ERROR_WANT_X509_LOOKUP: + return "application client cert callback asked to be called again"; + + case -WOLFSSL_ERROR_SSL: + return "fatal TLS protocol error"; + case BUFFER_ERROR : return "malformed buffer input error"; @@ -23250,7 +23262,7 @@ const char* wolfSSL_ERR_reason_error_string(unsigned long e) return "can't decode peer key"; case ZERO_RETURN: - case WOLFSSL_ERROR_ZERO_RETURN: + case -WOLFSSL_ERROR_ZERO_RETURN: return "peer sent close notify alert"; case ECC_CURVETYPE_ERROR: