Skip to content

Commit 6409b68

Browse files
Merge pull request #7698 from dgarske/asan_compat_list
Fix ASAN warning with compatibility layer cipher list parsing
2 parents 4ff0af7 + 7faf0dc commit 6409b68

3 files changed

Lines changed: 40 additions & 32 deletions

File tree

src/internal.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26539,8 +26539,11 @@ static int ParseCipherList(Suites* suites,
2653926539
return 0;
2654026540
}
2654126541

26542-
if (next[0] == 0 || XSTRCMP(next, "ALL") == 0 ||
26543-
XSTRCMP(next, "DEFAULT") == 0 || XSTRCMP(next, "HIGH") == 0) {
26542+
if (next[0] == '\0' ||
26543+
XSTRCMP(next, "ALL") == 0 ||
26544+
XSTRCMP(next, "DEFAULT") == 0 ||
26545+
XSTRCMP(next, "HIGH") == 0)
26546+
{
2654426547
/* Add all ciphersuites except anonymous and null ciphers. Prefer RSA */
2654526548
#ifndef NO_RSA
2654626549
haveRSA = 1;
@@ -26552,7 +26555,8 @@ static int ParseCipherList(Suites* suites,
2655226555
0,
2655326556
#endif
2655426557
haveRSA, 1, 1, !haveRSA, 1, haveRSA, !haveRSA, 1, 1, 0, 0,
26555-
side);
26558+
side
26559+
);
2655626560
return 1; /* wolfSSL default */
2655726561
}
2655826562

@@ -26572,6 +26576,8 @@ static int ParseCipherList(Suites* suites,
2657226576
if (length > currLen) {
2657326577
length = currLen;
2657426578
}
26579+
if (currLen == 0)
26580+
break;
2657526581
}
2657626582

2657726583
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL)
@@ -26893,7 +26899,7 @@ static int ParseCipherList(Suites* suites,
2689326899
}
2689426900
}
2689526901
}
26896-
while (next++); /* ++ needed to skip ':' */
26902+
while (next++); /* increment to skip ':' */
2689726903

2689826904
if (ret) {
2689926905
int keySz = 0;

src/ssl.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8354,6 +8354,7 @@ int tlsShowSecrets(WOLFSSL* ssl, void* secret, int secretSz,
83548354
/*
83558355
* check if the list has TLS13 and pre-TLS13 suites
83568356
* @param list cipher suite list that user want to set
8357+
* (caller required to check for NULL)
83578358
* @return mixed: 0, only pre-TLS13: 1, only TLS13: 2
83588359
*/
83598360
static int CheckcipherList(const char* list)
@@ -8376,15 +8377,20 @@ static int CheckcipherList(const char* list)
83768377

83778378
current_length = (!next) ? (word32)XSTRLEN(current)
83788379
: (word32)(next - current);
8380+
if (current_length == 0) {
8381+
break;
8382+
}
83798383

83808384
if (current_length < length) {
83818385
length = current_length;
83828386
}
83838387
XMEMCPY(name, current, length);
83848388
name[length] = 0;
83858389

8386-
if (XSTRCMP(name, "ALL") == 0 || XSTRCMP(name, "DEFAULT") == 0 ||
8387-
XSTRCMP(name, "HIGH") == 0) {
8390+
if (XSTRCMP(name, "ALL") == 0 ||
8391+
XSTRCMP(name, "DEFAULT") == 0 ||
8392+
XSTRCMP(name, "HIGH") == 0)
8393+
{
83888394
findTLSv13Suites = 1;
83898395
findbeforeSuites = 1;
83908396
break;
@@ -8412,7 +8418,7 @@ static int CheckcipherList(const char* list)
84128418
subStrNext = XSTRSTR(subStr, "+");
84138419

84148420
if ((XSTRCMP(subStr, "ECDHE") == 0) ||
8415-
(XSTRCMP(subStr, "RSA") == 0)) {
8421+
(XSTRCMP(subStr, "RSA") == 0)) {
84168422
return 0;
84178423
}
84188424

@@ -8428,7 +8434,7 @@ static int CheckcipherList(const char* list)
84288434
return 0;
84298435
}
84308436
}
8431-
while (next++); /* ++ needed to skip ':' */
8437+
while (next++); /* increment to skip ':' */
84328438

84338439
if (findTLSv13Suites == 0 && findbeforeSuites == 1) {
84348440
ret = 1;/* only before TLSv13 suites */

tests/api.c

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,8 @@ static int testDevId = INVALID_DEVID;
581581
#endif
582582

583583
#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) && !defined(NO_RSA) && \
584-
!defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT)
584+
!defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT) && \
585+
!defined(WOLFSSL_TIRTOS)
585586
#define HAVE_SSL_MEMIO_TESTS_DEPENDENCIES
586587
#endif
587588

@@ -8820,8 +8821,7 @@ static int test_wolfSSL_reuse_WOLFSSLobj(void)
88208821
return EXPECT_RESULT();
88218822
}
88228823

8823-
#if defined(OPENSSL_EXTRA) && !defined(WOLFSSL_TIRTOS) && \
8824-
defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES)
8824+
#if defined(OPENSSL_EXTRA) && defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES)
88258825
static int test_wolfSSL_CTX_verifyDepth_ServerClient_1_ctx_ready(
88268826
WOLFSSL_CTX* ctx)
88278827
{
@@ -8835,8 +8835,7 @@ static int test_wolfSSL_CTX_verifyDepth_ServerClient_1_ctx_ready(
88358835
static int test_wolfSSL_CTX_verifyDepth_ServerClient_1(void)
88368836
{
88378837
EXPECT_DECLS;
8838-
#if defined(OPENSSL_EXTRA) && !defined(WOLFSSL_TIRTOS) && \
8839-
defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES)
8838+
#if defined(OPENSSL_EXTRA) && defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES)
88408839
test_ssl_cbf client_cbf;
88418840
test_ssl_cbf server_cbf;
88428841

@@ -8855,14 +8854,12 @@ static int test_wolfSSL_CTX_verifyDepth_ServerClient_1(void)
88558854

88568855
ExpectIntEQ(client_cbf.return_code, TEST_SUCCESS);
88578856
ExpectIntEQ(server_cbf.return_code, TEST_SUCCESS);
8858-
#endif /* OPENSSL_EXTRA && !WOLFSSL_TIRTOS &&
8859-
* HAVE_SSL_MEMIO_TESTS_DEPENDENCIES */
8857+
#endif /* OPENSSL_EXTRA && HAVE_SSL_MEMIO_TESTS_DEPENDENCIES */
88608858

88618859
return EXPECT_RESULT();
88628860
}
88638861

8864-
#if defined(OPENSSL_EXTRA) && !defined(WOLFSSL_TIRTOS) && \
8865-
defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES)
8862+
#if defined(OPENSSL_EXTRA) && defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES)
88668863
static int test_wolfSSL_CTX_verifyDepth_ServerClient_2_ctx_ready(
88678864
WOLFSSL_CTX* ctx)
88688865
{
@@ -8876,8 +8873,7 @@ static int test_wolfSSL_CTX_verifyDepth_ServerClient_2_ctx_ready(
88768873
static int test_wolfSSL_CTX_verifyDepth_ServerClient_2(void)
88778874
{
88788875
EXPECT_DECLS;
8879-
#if defined(OPENSSL_EXTRA) && !defined(WOLFSSL_TIRTOS) && \
8880-
defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES)
8876+
#if defined(OPENSSL_EXTRA) && defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES)
88818877
test_ssl_cbf client_cbf;
88828878
test_ssl_cbf server_cbf;
88838879

@@ -8900,14 +8896,12 @@ static int test_wolfSSL_CTX_verifyDepth_ServerClient_2(void)
89008896

89018897
ExpectIntEQ(client_cbf.return_code, TEST_SUCCESS);
89028898
ExpectIntEQ(server_cbf.return_code, TEST_SUCCESS);
8903-
#endif /* OPENSSL_EXTRA && !WOLFSSL_TIRTOS &&
8904-
* HAVE_SSL_MEMIO_TESTS_DEPENDENCIES */
8899+
#endif /* OPENSSL_EXTRA && HAVE_SSL_MEMIO_TESTS_DEPENDENCIES */
89058900

89068901
return EXPECT_RESULT();
89078902
}
89088903

8909-
#if defined(OPENSSL_EXTRA) && !defined(WOLFSSL_TIRTOS) && \
8910-
defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES)
8904+
#if defined(OPENSSL_EXTRA) && defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES)
89118905
static int test_wolfSSL_CTX_verifyDepth_ServerClient_3_ctx_ready(
89128906
WOLFSSL_CTX* ctx)
89138907
{
@@ -8921,8 +8915,7 @@ static int test_wolfSSL_CTX_verifyDepth_ServerClient_3_ctx_ready(
89218915
static int test_wolfSSL_CTX_verifyDepth_ServerClient_3(void)
89228916
{
89238917
EXPECT_DECLS;
8924-
#if defined(OPENSSL_EXTRA) && !defined(WOLFSSL_TIRTOS) && \
8925-
defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES)
8918+
#if defined(OPENSSL_EXTRA) && defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES)
89268919
test_ssl_cbf client_cbf;
89278920
test_ssl_cbf server_cbf;
89288921

@@ -8947,15 +8940,14 @@ static int test_wolfSSL_CTX_verifyDepth_ServerClient_3(void)
89478940
ExpectIntEQ(server_cbf.return_code, TEST_FAIL);
89488941
ExpectIntEQ(client_cbf.last_err, MAX_CHAIN_ERROR);
89498942
ExpectIntEQ(server_cbf.last_err, FATAL_ERROR);
8950-
#endif /* OPENSSL_EXTRA && !WOLFSSL_TIRTOS &&
8951-
* HAVE_SSL_MEMIO_TESTS_DEPENDENCIES */
8943+
#endif /* OPENSSL_EXTRA && HAVE_SSL_MEMIO_TESTS_DEPENDENCIES */
89528944

89538945
return EXPECT_RESULT();
89548946
}
89558947

89568948
#if defined(OPENSSL_ALL) && defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES) && \
8957-
!defined(WOLFSSL_TIRTOS) && !defined(NO_AES) && !defined(WOLFSSL_NO_TLS12) \
8958-
&& !defined(NO_SHA256) && defined(HAVE_ECC)
8949+
!defined(WOLFSSL_NO_TLS12) && \
8950+
defined(HAVE_ECC) && !defined(NO_AES) && !defined(NO_SHA256)
89598951
static int test_wolfSSL_CTX_set_cipher_list_server_ctx_ready(WOLFSSL_CTX* ctx)
89608952
{
89618953
EXPECT_DECLS;
@@ -8975,8 +8967,9 @@ static int test_wolfSSL_CTX_set_cipher_list(void)
89758967
{
89768968
EXPECT_DECLS;
89778969
#if defined(OPENSSL_ALL) && defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES) && \
8978-
!defined(WOLFSSL_TIRTOS) && !defined(NO_AES) && !defined(WOLFSSL_NO_TLS12) \
8979-
&& !defined(NO_SHA256) && defined(HAVE_ECC)
8970+
defined(HAVE_ECC) && !defined(NO_AES) && !defined(NO_SHA256)
8971+
8972+
#if !defined(WOLFSSL_NO_TLS12)
89808973
WOLFSSL_CTX* ctxClient = NULL;
89818974
WOLFSSL* sslClient = NULL;
89828975
test_ssl_cbf client_cbf;
@@ -8998,7 +8991,8 @@ static int test_wolfSSL_CTX_set_cipher_list(void)
89988991

89998992
/* check with cipher string that has '+' */
90008993
ExpectNotNull((ctxClient = wolfSSL_CTX_new(wolfTLSv1_2_client_method())));
9001-
ExpectTrue(wolfSSL_CTX_set_cipher_list(ctxClient, "ECDHE+AESGCM"));
8994+
/* Use trailing : with nothing to test for ASAN */
8995+
ExpectTrue(wolfSSL_CTX_set_cipher_list(ctxClient, "ECDHE+AESGCM:"));
90028996
ExpectNotNull((sslClient = wolfSSL_new(ctxClient)));
90038997

90048998
/* check for the existence of an ECDHE ECDSA cipher suite */
@@ -9026,6 +9020,8 @@ static int test_wolfSSL_CTX_set_cipher_list(void)
90269020

90279021
wolfSSL_free(sslClient);
90289022
wolfSSL_CTX_free(ctxClient);
9023+
9024+
#endif /* !WOLFSSL_NO_TLS12 */
90299025
#endif
90309026
return EXPECT_RESULT();
90319027
}

0 commit comments

Comments
 (0)