Skip to content

Commit

Permalink
Merge pull request #6904 from julek-wolfssl/suites-allocation
Browse files Browse the repository at this point in the history
Don't try to allocate 0 size suites copy. Fixes `--enable-trackmemory --enable-smallstack CFLAGS="-DALT_ECC_SIZE" --enable-opensslextra` errors.
  • Loading branch information
bandi13 authored Oct 24, 2023
2 parents 13cadbb + 4aad758 commit a74228b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -11656,7 +11656,7 @@ static int wolfSSL_parse_cipher_list(WOLFSSL_CTX* ctx, Suites* suites,
#ifndef WOLFSSL_SMALL_STACK
byte suitesCpy[WOLFSSL_MAX_SUITE_SZ];
#else
byte* suitesCpy;
byte* suitesCpy = NULL;
#endif
word16 suitesCpySz = 0;
word16 i = 0;
Expand Down Expand Up @@ -11696,12 +11696,16 @@ static int wolfSSL_parse_cipher_list(WOLFSSL_CTX* ctx, Suites* suites,
/* list contains ciphers either only for TLS 1.3 or <= TLS 1.2 */

#ifdef WOLFSSL_SMALL_STACK
suitesCpy = (byte*)XMALLOC(suites->suiteSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (suitesCpy == NULL)
return WOLFSSL_FAILURE;
if (suites->suiteSz > 0) {
suitesCpy = (byte*)XMALLOC(suites->suiteSz, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
if (suitesCpy == NULL)
return WOLFSSL_FAILURE;
}
#endif

XMEMCPY(suitesCpy, suites->suites, suites->suiteSz);
if (suites->suiteSz > 0)
XMEMCPY(suitesCpy, suites->suites, suites->suiteSz);
suitesCpySz = suites->suiteSz;

ret = SetCipherList(ctx, suites, list);
Expand Down

0 comments on commit a74228b

Please sign in to comment.