@@ -1474,18 +1474,35 @@ WOLFSSL* wolfSSL_new(WOLFSSL_CTX* ctx)
14741474
14751475 WOLFSSL_ENTER("wolfSSL_new");
14761476
1477- if (ctx == NULL)
1478- return ssl;
1477+ if (ctx == NULL) {
1478+ WOLFSSL_MSG("wolfSSL_new ctx is null");
1479+ return NULL;
1480+ }
14791481
14801482 ssl = (WOLFSSL*) XMALLOC(sizeof(WOLFSSL), ctx->heap, DYNAMIC_TYPE_SSL);
1481- if (ssl) {
1482- if ( (ret = InitSSL(ssl, ctx, 0)) < 0) {
1483+
1484+ if (ssl == NULL) {
1485+ WOLFSSL_MSG_EX("ssl xmalloc failed to allocate %d bytes",
1486+ (int)sizeof(WOLFSSL));
1487+ }
1488+ else {
1489+ ret = InitSSL(ssl, ctx, 0);
1490+ if (ret < 0) {
1491+ WOLFSSL_MSG_EX("wolfSSL_new failed during InitSSL. err = %d", ret);
14831492 FreeSSL(ssl, ctx->heap);
1484- ssl = 0 ;
1493+ ssl = NULL ;
14851494 }
1486- }
1495+ else if (ret == 0) {
1496+ WOLFSSL_MSG("wolfSSL_new InitSSL success");
1497+ }
1498+ else {
1499+ /* Only success (0) or negative values should ever be seen. */
1500+ WOLFSSL_MSG_EX("WARNING: wolfSSL_new unexpected InitSSL return"
1501+ " value = %d", ret);
1502+ } /* InitSSL check */
1503+ } /* ssl XMALLOC success */
14871504
1488- WOLFSSL_LEAVE("wolfSSL_new", ret);
1505+ WOLFSSL_LEAVE("wolfSSL_new InitSSL = ", ret);
14891506 (void)ret;
14901507
14911508 return ssl;
@@ -1496,8 +1513,14 @@ WOLFSSL_ABI
14961513void wolfSSL_free(WOLFSSL* ssl)
14971514{
14981515 WOLFSSL_ENTER("wolfSSL_free");
1499- if (ssl)
1516+
1517+ if (ssl) {
1518+ WOLFSSL_MSG_EX("Free SSL: %p", (uintptr_t)ssl);
15001519 FreeSSL(ssl, ssl->ctx->heap);
1520+ }
1521+ else {
1522+ WOLFSSL_MSG("Free SSL: wolfSSL_free already null");
1523+ }
15011524 WOLFSSL_LEAVE("wolfSSL_free", 0);
15021525}
15031526
@@ -11906,7 +11929,10 @@ static int wolfSSL_parse_cipher_list(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
1190611929 }
1190711930
1190811931 /* list contains ciphers either only for TLS 1.3 or <= TLS 1.2 */
11909-
11932+ if (suites->suiteSz == 0) {
11933+ WOLFSSL_MSG("Warning suites->suiteSz = 0 set to WOLFSSL_MAX_SUITE_SZ");
11934+ suites->suiteSz = WOLFSSL_MAX_SUITE_SZ;
11935+ }
1191011936#ifdef WOLFSSL_SMALL_STACK
1191111937 if (suites->suiteSz > 0) {
1191211938 suitesCpy = (byte*)XMALLOC(suites->suiteSz, NULL,
@@ -12598,10 +12624,13 @@ int wolfSSL_DTLS_SetCookieSecret(WOLFSSL* ssl,
1259812624 return wolfSSL_connect_TLSv13(ssl);
1259912625 #else
1260012626 #ifdef WOLFSSL_TLS13
12601- if (ssl->options.tls1_3)
12627+ if (ssl->options.tls1_3) {
12628+ WOLFSSL_MSG("TLS 1.3");
1260212629 return wolfSSL_connect_TLSv13(ssl);
12630+ }
1260312631 #endif
1260412632
12633+ WOLFSSL_MSG("TLS 1.2 or lower");
1260512634 WOLFSSL_ENTER("wolfSSL_connect");
1260612635
1260712636 /* make sure this wolfSSL object has arrays and rng setup. Protects
@@ -12719,11 +12748,14 @@ int wolfSSL_DTLS_SetCookieSecret(WOLFSSL* ssl,
1271912748 neededState = SERVER_HELLOVERIFYREQUEST_COMPLETE;
1272012749 #endif
1272112750 /* get response */
12751+ WOLFSSL_MSG("Server state up to needed state.");
1272212752 while (ssl->options.serverState < neededState) {
12753+ WOLFSSL_MSG("Progressing server state...");
1272312754 #ifdef WOLFSSL_TLS13
1272412755 if (ssl->options.tls1_3)
1272512756 return wolfSSL_connect_TLSv13(ssl);
1272612757 #endif
12758+ WOLFSSL_MSG("ProcessReply...");
1272712759 if ( (ssl->error = ProcessReply(ssl)) < 0) {
1272812760 WOLFSSL_ERROR(ssl->error);
1272912761 return WOLFSSL_FATAL_ERROR;
@@ -12739,6 +12771,7 @@ int wolfSSL_DTLS_SetCookieSecret(WOLFSSL* ssl,
1273912771 neededState = SERVER_HELLODONE_COMPLETE;
1274012772 }
1274112773 }
12774+ WOLFSSL_MSG("ProcessReply done.");
1274212775
1274312776#ifdef WOLFSSL_DTLS13
1274412777 if (ssl->options.dtls && IsAtLeastTLSv1_3(ssl->version)
@@ -16903,6 +16936,11 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
1690316936 }
1690416937#endif
1690516938
16939+ #ifdef NO_FILESYSTEM
16940+ WOLFSSL_MSG("wolfSSL_CTX_set_default_verify_paths not supported"
16941+ " with NO_FILESYSTEM enabled");
16942+ ret = WOLFSSL_FATAL_ERROR;
16943+ #else
1690616944 ret = wolfSSL_CTX_load_system_CA_certs(ctx);
1690716945 if (ret == WOLFSSL_BAD_PATH) {
1690816946 /*
@@ -16911,6 +16949,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
1691116949 */
1691216950 ret = WOLFSSL_SUCCESS;
1691316951 }
16952+ #endif
1691416953
1691516954 WOLFSSL_LEAVE("wolfSSL_CTX_set_default_verify_paths", ret);
1691616955
0 commit comments