Skip to content

Commit 4aad758

Browse files
committed
Don't try to allocate 0 size suites copy
1 parent 13cadbb commit 4aad758

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/ssl.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11656,7 +11656,7 @@ static int wolfSSL_parse_cipher_list(WOLFSSL_CTX* ctx, Suites* suites,
1165611656
#ifndef WOLFSSL_SMALL_STACK
1165711657
byte suitesCpy[WOLFSSL_MAX_SUITE_SZ];
1165811658
#else
11659-
byte* suitesCpy;
11659+
byte* suitesCpy = NULL;
1166011660
#endif
1166111661
word16 suitesCpySz = 0;
1166211662
word16 i = 0;
@@ -11696,12 +11696,16 @@ static int wolfSSL_parse_cipher_list(WOLFSSL_CTX* ctx, Suites* suites,
1169611696
/* list contains ciphers either only for TLS 1.3 or <= TLS 1.2 */
1169711697

1169811698
#ifdef WOLFSSL_SMALL_STACK
11699-
suitesCpy = (byte*)XMALLOC(suites->suiteSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
11700-
if (suitesCpy == NULL)
11701-
return WOLFSSL_FAILURE;
11699+
if (suites->suiteSz > 0) {
11700+
suitesCpy = (byte*)XMALLOC(suites->suiteSz, NULL,
11701+
DYNAMIC_TYPE_TMP_BUFFER);
11702+
if (suitesCpy == NULL)
11703+
return WOLFSSL_FAILURE;
11704+
}
1170211705
#endif
1170311706

11704-
XMEMCPY(suitesCpy, suites->suites, suites->suiteSz);
11707+
if (suites->suiteSz > 0)
11708+
XMEMCPY(suitesCpy, suites->suites, suites->suiteSz);
1170511709
suitesCpySz = suites->suiteSz;
1170611710

1170711711
ret = SetCipherList(ctx, suites, list);

0 commit comments

Comments
 (0)