Skip to content

Commit 86db2d4

Browse files
authored
Merge pull request wolfSSL#10041 from douzzer/20260322-various-fixes
20260322-various-fixes
2 parents 20f640a + b8f9b06 commit 86db2d4

File tree

9 files changed

+32
-22
lines changed

9 files changed

+32
-22
lines changed

examples/client/client.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ static int SMTP_Shutdown(WOLFSSL* ssl, int wc_shutdown)
10441044
printf("%s\n", tmpBuf);
10451045

10461046
ret = wolfSSL_shutdown(ssl);
1047-
if (wc_shutdown && ret == WOLFSSL_SHUTDOWN_NOT_DONE) {
1047+
if (wc_shutdown && ret == WC_NO_ERR_TRACE(WOLFSSL_SHUTDOWN_NOT_DONE)) {
10481048
if (tcp_select(wolfSSL_get_fd(ssl), DEFAULT_TIMEOUT_SEC) ==
10491049
TEST_RECV_READY) {
10501050
ret = wolfSSL_shutdown(ssl); /* bidirectional shutdown */
@@ -4687,15 +4687,15 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
46874687
#endif
46884688

46894689
ret = wolfSSL_shutdown(ssl);
4690-
if (wc_shutdown && ret == WOLFSSL_SHUTDOWN_NOT_DONE) {
4690+
if (wc_shutdown && ret == WC_NO_ERR_TRACE(WOLFSSL_SHUTDOWN_NOT_DONE)) {
46914691
while (tcp_select(wolfSSL_get_fd(ssl), DEFAULT_TIMEOUT_SEC) ==
46924692
TEST_RECV_READY) {
46934693
ret = wolfSSL_shutdown(ssl); /* bidirectional shutdown */
46944694
if (ret == WOLFSSL_SUCCESS) {
46954695
printf("Bidirectional shutdown complete\n");
46964696
break;
46974697
}
4698-
else if (ret != WOLFSSL_SHUTDOWN_NOT_DONE) {
4698+
else if (ret != WC_NO_ERR_TRACE(WOLFSSL_SHUTDOWN_NOT_DONE)) {
46994699
LOG_ERROR("Bidirectional shutdown failed\n");
47004700
break;
47014701
}
@@ -4932,7 +4932,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
49324932
sendGET, " resume", 0);
49334933

49344934
ret = wolfSSL_shutdown(sslResume);
4935-
if (wc_shutdown && ret == WOLFSSL_SHUTDOWN_NOT_DONE)
4935+
if (wc_shutdown && ret == WC_NO_ERR_TRACE(WOLFSSL_SHUTDOWN_NOT_DONE))
49364936
wolfSSL_shutdown(sslResume); /* bidirectional shutdown */
49374937

49384938
/* display collected statistics */

examples/server/server.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4044,15 +4044,15 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
40444044
#endif /* WOLFSSL_DTLS13 */
40454045

40464046
ret = SSL_shutdown(ssl);
4047-
if (wc_shutdown && ret == WOLFSSL_SHUTDOWN_NOT_DONE) {
4047+
if (wc_shutdown && ret == WC_NO_ERR_TRACE(WOLFSSL_SHUTDOWN_NOT_DONE)) {
40484048
while (tcp_select(wolfSSL_get_fd(ssl), DEFAULT_TIMEOUT_SEC) ==
40494049
TEST_RECV_READY) {
40504050
ret = wolfSSL_shutdown(ssl); /* bidirectional shutdown */
40514051
if (ret == WOLFSSL_SUCCESS) {
40524052
printf("Bidirectional shutdown complete\n");
40534053
break;
40544054
}
4055-
else if (ret != WOLFSSL_SHUTDOWN_NOT_DONE) {
4055+
else if (ret != WC_NO_ERR_TRACE(WOLFSSL_SHUTDOWN_NOT_DONE)) {
40564056
LOG_ERROR("Bidirectional shutdown failed\n");
40574057
break;
40584058
}

src/bio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2646,7 +2646,7 @@ int wolfSSL_BIO_flush(WOLFSSL_BIO* bio)
26462646

26472647
if (b->ptr.ssl != NULL) {
26482648
int rc = wolfSSL_shutdown(b->ptr.ssl);
2649-
if (rc == WOLFSSL_SHUTDOWN_NOT_DONE) {
2649+
if (rc == WC_NO_ERR_TRACE(WOLFSSL_SHUTDOWN_NOT_DONE)) {
26502650
/* In this case, call again to give us a chance to read the
26512651
* close notify alert from the other end. */
26522652
wolfSSL_shutdown(b->ptr.ssl);

src/keys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3571,7 +3571,7 @@ int SetKeysSide(WOLFSSL* ssl, enum encrypt_side side)
35713571
#endif
35723572

35733573
#if !defined(NO_CERTS) && defined(HAVE_PK_CALLBACKS)
3574-
ret = PROTOCOLCB_UNAVAILABLE;
3574+
ret = WC_NO_ERR_TRACE(PROTOCOLCB_UNAVAILABLE);
35753575
if (ssl->ctx->EncryptKeysCb) {
35763576
void* ctx = wolfSSL_GetEncryptKeysCtx(ssl);
35773577
#if defined(WOLFSSL_RENESAS_FSPSM_TLS)

src/tls13.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ static int Tls13HKDFExpandKeyLabel(WOLFSSL* ssl, byte* okm, word32 okmLen,
234234
{
235235
int ret;
236236
#if defined(HAVE_PK_CALLBACKS)
237-
ret = NOT_COMPILED_IN;
237+
ret = WC_NO_ERR_TRACE(NOT_COMPILED_IN);
238238
if (ssl->ctx && ssl->ctx->HKDFExpandLabelCb) {
239239
ret = ssl->ctx->HKDFExpandLabelCb(okm, okmLen, prk, prkLen,
240240
protocol, protocolLen,
@@ -2662,7 +2662,7 @@ static int EncryptTls13(WOLFSSL* ssl, byte* output, const byte* input,
26622662
nonceSz = AESGCM_NONCE_SZ;
26632663

26642664
#if defined(HAVE_PK_CALLBACKS)
2665-
ret = NOT_COMPILED_IN;
2665+
ret = WC_NO_ERR_TRACE(NOT_COMPILED_IN);
26662666
if (ssl->ctx && ssl->ctx->PerformTlsRecordProcessingCb) {
26672667
ret = ssl->ctx->PerformTlsRecordProcessingCb(ssl, 1,
26682668
output, input, dataSz,
@@ -2704,7 +2704,7 @@ static int EncryptTls13(WOLFSSL* ssl, byte* output, const byte* input,
27042704

27052705
nonceSz = AESCCM_NONCE_SZ;
27062706
#if defined(HAVE_PK_CALLBACKS)
2707-
ret = NOT_COMPILED_IN;
2707+
ret = WC_NO_ERR_TRACE(NOT_COMPILED_IN);
27082708
if (ssl->ctx && ssl->ctx->PerformTlsRecordProcessingCb) {
27092709
ret = ssl->ctx->PerformTlsRecordProcessingCb(ssl, 1,
27102710
output, input, dataSz,
@@ -3063,7 +3063,7 @@ int DecryptTls13(WOLFSSL* ssl, byte* output, const byte* input, word16 sz,
30633063
nonceSz = AESGCM_NONCE_SZ;
30643064

30653065
#if defined(HAVE_PK_CALLBACKS)
3066-
ret = NOT_COMPILED_IN;
3066+
ret = WC_NO_ERR_TRACE(NOT_COMPILED_IN);
30673067
if (ssl->ctx && ssl->ctx->PerformTlsRecordProcessingCb) {
30683068
ret = ssl->ctx->PerformTlsRecordProcessingCb(ssl, 0,
30693069
output, input, dataSz,
@@ -3102,7 +3102,7 @@ int DecryptTls13(WOLFSSL* ssl, byte* output, const byte* input, word16 sz,
31023102

31033103
nonceSz = AESCCM_NONCE_SZ;
31043104
#if defined(HAVE_PK_CALLBACKS)
3105-
ret = NOT_COMPILED_IN;
3105+
ret = WC_NO_ERR_TRACE(NOT_COMPILED_IN);
31063106
if (ssl->ctx && ssl->ctx->PerformTlsRecordProcessingCb) {
31073107
ret = ssl->ctx->PerformTlsRecordProcessingCb(ssl, 0,
31083108
output, input, dataSz,
@@ -6892,7 +6892,7 @@ int DoTls13ClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
68926892
#endif
68936893
{
68946894
/* Reset state */
6895-
ret = VERSION_ERROR;
6895+
ret = WC_NO_ERR_TRACE(VERSION_ERROR);
68966896
ssl->options.asyncState = TLS_ASYNC_BEGIN;
68976897
XMEMSET(args, 0, sizeof(Dch13Args));
68986898
#ifdef WOLFSSL_ASYNC_CRYPT

tests/api.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6713,13 +6713,15 @@ static int test_wolfSSL_read_write_ex(void)
67136713

67146714
ExpectIntEQ(wolfSSL_shutdown(ssl_c), WOLFSSL_SHUTDOWN_NOT_DONE);
67156715
ExpectIntEQ(wolfSSL_shutdown(ssl_s), WOLFSSL_SHUTDOWN_NOT_DONE);
6716-
ExpectIntEQ(wolfSSL_shutdown(ssl_c), 1);
6717-
ExpectIntEQ(wolfSSL_shutdown(ssl_s), 1);
6716+
ExpectIntEQ(wolfSSL_shutdown(ssl_c), WOLFSSL_SUCCESS);
6717+
ExpectIntEQ(wolfSSL_shutdown(ssl_s), WOLFSSL_SUCCESS);
67186718

67196719
wolfSSL_free(ssl_c);
67206720
wolfSSL_free(ssl_s);
67216721
wolfSSL_CTX_free(ctx_c);
67226722
wolfSSL_CTX_free(ctx_s);
6723+
6724+
/* XXX this should be return EXPECT_RESULT(); */
67236725
return TEST_SUCCESS;
67246726
}
67256727

@@ -25691,7 +25693,7 @@ static THREAD_RETURN WOLFSSL_THREAD SSL_read_test_client_thread(void* args)
2569125693

2569225694
if (EXPECT_SUCCESS()) {
2569325695
ret = wolfSSL_shutdown(ssl);
25694-
if (ret == WOLFSSL_SHUTDOWN_NOT_DONE) {
25696+
if (ret == WC_NO_ERR_TRACE(WOLFSSL_SHUTDOWN_NOT_DONE)) {
2569525697
ret = wolfSSL_shutdown(ssl);
2569625698
}
2569725699
}
@@ -29286,7 +29288,7 @@ static void test_ticket_and_psk_mixing_on_result(WOLFSSL* ssl)
2928629288
}
2928729289
do {
2928829290
ret = wolfSSL_shutdown(ssl);
29289-
} while (ret == WOLFSSL_SHUTDOWN_NOT_DONE);
29291+
} while (ret == WC_NO_ERR_TRACE(WOLFSSL_SHUTDOWN_NOT_DONE));
2929029292
AssertIntEQ(wolfSSL_clear(ssl), WOLFSSL_SUCCESS);
2929129293
wolfSSL_set_psk_callback_ctx(ssl, (void*)"TLS13-AES256-GCM-SHA384");
2929229294
#ifndef OPENSSL_COMPATIBLE_DEFAULTS
@@ -29377,7 +29379,7 @@ static void test_prioritize_psk_on_result(WOLFSSL* ssl)
2937729379
}
2937829380
do {
2937929381
ret = wolfSSL_shutdown(ssl);
29380-
} while (ret == WOLFSSL_SHUTDOWN_NOT_DONE);
29382+
} while (ret == WC_NO_ERR_TRACE(WOLFSSL_SHUTDOWN_NOT_DONE));
2938129383
AssertIntEQ(wolfSSL_clear(ssl), WOLFSSL_SUCCESS);
2938229384
wolfSSL_set_psk_callback_ctx(ssl, (void*)"TLS13-AES256-GCM-SHA384");
2938329385
/* Previous connection was made with TLS13-AES128-GCM-SHA256. Order is

wolfcrypt/src/logging.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,7 @@ int wc_backtrace_render(void) {
19391939
int cur_init_count = wolfSSL_Atomic_Int_FetchSub(&init_count, 1);
19401940
if (cur_init_count != 0) {
19411941
(void)wolfSSL_Atomic_Int_FetchAdd(&init_count, 1);
1942-
return DEADLOCK_AVERTED_E;
1942+
return WC_NO_ERR_TRACE(DEADLOCK_AVERTED_E);
19431943
}
19441944
ret = wc_InitMutex(&backtrace_mutex);
19451945
if (ret != 0)
@@ -1960,7 +1960,7 @@ int wc_backtrace_render(void) {
19601960
if (backtrace_state == NULL) {
19611961
if (backtrace_init(&backtrace_state) < 0) {
19621962
wc_UnLockMutex(&backtrace_mutex);
1963-
return BAD_STATE_E;
1963+
return WC_NO_ERR_TRACE(BAD_STATE_E);
19641964
}
19651965
}
19661966

wolfssl/ssl.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3075,6 +3075,14 @@ enum { /* ssl Constants */
30753075
WOLFSSL_SHUTDOWN_NOT_DONE = 2,
30763076
#endif
30773077

3078+
#if defined(WOLFSSL_DEBUG_TRACE_ERROR_CODES) && \
3079+
(defined(BUILDING_WOLFSSL) || \
3080+
defined(WOLFSSL_DEBUG_TRACE_ERROR_CODES_ALWAYS))
3081+
#define WOLFSSL_SHUTDOWN_NOT_DONE \
3082+
WC_ERR_TRACE(WOLFSSL_SHUTDOWN_NOT_DONE)
3083+
#define CONST_NUM_ERR_WOLFSSL_SHUTDOWN_NOT_DONE 0
3084+
#endif
3085+
30783086
WOLFSSL_FILETYPE_ASN1 = CTC_FILETYPE_ASN1,
30793087
WOLFSSL_FILETYPE_PEM = CTC_FILETYPE_PEM,
30803088
WOLFSSL_FILETYPE_DEFAULT = CTC_FILETYPE_ASN1, /* ASN1 */

wolfssl/wolfcrypt/error-crypt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ WOLFSSL_ABI WOLFSSL_API const char* wc_GetErrorString(int error);
355355
#endif
356356
#ifndef WC_ERR_TRACE
357357
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
358-
#define WC_ERR_TRACE(label) \
358+
#define WC_ERR_TRACE(label) __extension__ \
359359
({ if (wc_debug_trace_error_codes_enabled()) { \
360360
(void)WOLFSSL_DEBUG_PRINTF_FN( \
361361
WOLFSSL_DEBUG_PRINTF_FIRST_ARGS \

0 commit comments

Comments
 (0)