Skip to content

Commit d49308e

Browse files
authored
Merge pull request #7634 from douzzer/20240608-WOLFSSL_DEBUG_TRACE_ERROR_CODES
20240608-WOLFSSL_DEBUG_TRACE_ERROR_CODES
2 parents ac459e3 + 1b907d0 commit d49308e

76 files changed

Lines changed: 1057 additions & 789 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

configure.ac

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,17 @@ AS_IF([test "$ax_enable_debug" = "yes"],
200200
[AM_CCASFLAGS="$DEBUG_CFLAGS $AM_CCASFLAGS"],
201201
[AM_CCASFLAGS="$AM_CCASFLAGS -DNDEBUG"])
202202

203+
AC_ARG_ENABLE([debug-trace-errcodes],
204+
[ AS_HELP_STRING([--enable-debug-trace-errcodes],[Print trace messages when library errors are thrown.]) ],
205+
[ ENABLED_DEBUG_TRACE_ERRCODES=$enableval ],
206+
[ ENABLED_DEBUG_TRACE_ERRCODES=no ]
207+
)
208+
209+
if test "$ENABLED_DEBUG_TRACE_ERRCODES" = "yes"
210+
then
211+
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DEBUG_TRACE_ERROR_CODES"
212+
fi
213+
203214
# Start without certificates enabled and enable if a certificate algorithm is
204215
# enabled
205216
ENABLED_CERTS="no"
@@ -9788,6 +9799,11 @@ echo "" >> $OPTION_FILE
97889799
echo "#endif /* WOLFSSL_OPTIONS_H */" >> $OPTION_FILE
97899800
echo "" >> $OPTION_FILE
97909801
9802+
if test "$ENABLED_DEBUG_TRACE_ERRCODES" = "yes"
9803+
then
9804+
support/gen-debug-trace-error-codes.sh || AC_MSG_ERROR([Header generation for debug-trace-errcodes failed.])
9805+
fi
9806+
97919807
if test "$ENABLED_OPENSSLEXTRA" = "yes" && test "$ENABLED_LINUXKM" = "no"
97929808
then
97939809
SAVE_CFLAGS=$CFLAGS

src/bio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ static int wolfSSL_BIO_BASE64_write(WOLFSSL_BIO* bio, const void* data,
403403
/* get the encoded length */
404404
if (bio->flags & WOLFSSL_BIO_FLAG_BASE64_NO_NL) {
405405
if (Base64_Encode_NoNl((const byte*)data, inLen, NULL,
406-
&sz) != LENGTH_ONLY_E) {
406+
&sz) != WC_NO_ERR_TRACE(LENGTH_ONLY_E)) {
407407
WOLFSSL_MSG("Error with base64 get length");
408408
return WOLFSSL_FATAL_ERROR;
409409
}

src/crl.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ int CheckCertCRL_ex(WOLFSSL_CRL* crl, byte* issuerHash, byte* serial,
503503
/* Loading <issuer-hash>.rN form CRL file if find at the folder, */
504504
/* and try again checking Cert in the CRL list. */
505505
/* When not set the folder or not use hash_dir, do nothing. */
506-
if ((foundEntry == 0) && (ret != OCSP_WANT_READ)) {
506+
if ((foundEntry == 0) && (ret != WC_NO_ERR_TRACE(OCSP_WANT_READ))) {
507507
if (crl->cm != NULL && crl->cm->x509_store_p != NULL) {
508508
ret = LoadCertByIssuer(crl->cm->x509_store_p,
509509
(WOLFSSL_X509_NAME*)issuerName, X509_LU_CRL);
@@ -517,7 +517,7 @@ int CheckCertCRL_ex(WOLFSSL_CRL* crl, byte* issuerHash, byte* serial,
517517
#endif
518518
if (foundEntry == 0) {
519519
WOLFSSL_MSG("Couldn't find CRL for status check");
520-
if (ret != CRL_CERT_DATE_ERR) {
520+
if (ret != WC_NO_ERR_TRACE(CRL_CERT_DATE_ERR)) {
521521
ret = CRL_MISSING;
522522
}
523523

@@ -655,13 +655,15 @@ int BufferLoadCRL(WOLFSSL_CRL* crl, const byte* buff, long sz, int type,
655655
InitDecodedCRL(dcrl, crl->heap);
656656
ret = ParseCRL(crl->currentEntry->certs, dcrl, myBuffer, (word32)sz,
657657
verify, crl->cm);
658-
if (ret != 0 && !(ret == ASN_CRL_NO_SIGNER_E && verify == NO_VERIFY)) {
658+
if (ret != 0 && !(ret == WC_NO_ERR_TRACE(ASN_CRL_NO_SIGNER_E)
659+
&& verify == NO_VERIFY)) {
659660
WOLFSSL_MSG("ParseCRL error");
660661
CRL_Entry_free(crl->currentEntry, crl->heap);
661662
crl->currentEntry = NULL;
662663
}
663664
else {
664-
ret = AddCRL(crl, dcrl, myBuffer, ret != ASN_CRL_NO_SIGNER_E);
665+
ret = AddCRL(crl, dcrl, myBuffer,
666+
ret != WC_NO_ERR_TRACE(ASN_CRL_NO_SIGNER_E));
665667
if (ret != 0) {
666668
WOLFSSL_MSG("AddCRL error");
667669
crl->currentEntry = NULL;

src/dtls.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ int DtlsIgnoreError(int err)
107107
{
108108
/* Whitelist of errors not to ignore */
109109
switch (err) {
110-
case MEMORY_E:
111-
case MEMORY_ERROR:
112-
case ASYNC_INIT_E:
113-
case ASYNC_OP_E:
114-
case SOCKET_ERROR_E:
115-
case WANT_READ:
116-
case WANT_WRITE:
117-
case COOKIE_ERROR:
110+
case WC_NO_ERR_TRACE(MEMORY_E):
111+
case WC_NO_ERR_TRACE(MEMORY_ERROR):
112+
case WC_NO_ERR_TRACE(ASYNC_INIT_E):
113+
case WC_NO_ERR_TRACE(ASYNC_OP_E):
114+
case WC_NO_ERR_TRACE(SOCKET_ERROR_E):
115+
case WC_NO_ERR_TRACE(WANT_READ):
116+
case WC_NO_ERR_TRACE(WANT_WRITE):
117+
case WC_NO_ERR_TRACE(COOKIE_ERROR):
118118
return 0;
119119
default:
120120
return 1;
@@ -267,7 +267,7 @@ static int CheckDtlsCookie(const WOLFSSL* ssl, WolfSSL_CH* ch,
267267
return BUFFER_E;
268268
ret = TlsCheckCookie(ssl, ch->cookieExt.elements + OPAQUE16_LEN,
269269
(word16)(ch->cookieExt.size - OPAQUE16_LEN));
270-
if (ret < 0 && ret != HRR_COOKIE_ERROR)
270+
if (ret < 0 && ret != WC_NO_ERR_TRACE(HRR_COOKIE_ERROR))
271271
return ret;
272272
*cookieGood = ret > 0;
273273
ret = 0;

src/dtls13.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,8 @@ int Dtls13ProcessBufferedMessages(WOLFSSL* ssl)
396396
* WANT_WRITE means that we are done with processing the msg and we are
397397
* waiting to flush the output buffer. */
398398
if ((ret == 0 || ret == WANT_WRITE) || (msg->type == certificate_request &&
399-
ssl->options.handShakeDone && ret == WC_PENDING_E)) {
399+
ssl->options.handShakeDone &&
400+
ret == WC_NO_ERR_TRACE(WC_PENDING_E))) {
400401
if (IsAtLeastTLSv1_3(ssl->version))
401402
Dtls13MsgWasProcessed(ssl, (enum HandShakeType)msg->type);
402403
else if (downgraded)

0 commit comments

Comments
 (0)