Skip to content

Commit 5b2e8b1

Browse files
authored
Merge pull request #10065 from dgarske/async_nb_leak
Fix possible leak for ecc non-blocking crypto
2 parents edb4b28 + 6cc94b0 commit 5b2e8b1

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

src/tls.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8579,8 +8579,15 @@ static int TLSX_KeyShare_GenEccKey(WOLFSSL *ssl, KeyShareEntry* kse)
85798579
/* Cleanup on error, otherwise data owned by key share entry */
85808580
XFREE(kse->pubKey, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY);
85818581
kse->pubKey = NULL;
8582-
if (eccKey != NULL)
8582+
if (eccKey != NULL) {
8583+
#if defined(WC_ECC_NONBLOCK) && defined(WOLFSSL_ASYNC_CRYPT_SW) && \
8584+
defined(WC_ASYNC_ENABLE_ECC)
8585+
if (eccKey->nb_ctx != NULL) {
8586+
XFREE(eccKey->nb_ctx, ssl->heap, DYNAMIC_TYPE_TMP_BUFFER);
8587+
}
8588+
#endif
85838589
wc_ecc_free(eccKey);
8590+
}
85848591
XFREE(kse->key, ssl->heap, DYNAMIC_TYPE_PRIVATE_KEY);
85858592
kse->key = NULL;
85868593
}
@@ -9817,8 +9824,14 @@ static int TLSX_KeyShare_ProcessEcc_ex(WOLFSSL* ssl,
98179824
ssl->peerEccKey = NULL;
98189825
ssl->peerEccKeyPresent = 0;
98199826
}
9820-
if (keyShareEntry->key) {
9821-
wc_ecc_free((ecc_key*)keyShareEntry->key);
9827+
if (eccKey != NULL) {
9828+
#if defined(WC_ECC_NONBLOCK) && defined(WOLFSSL_ASYNC_CRYPT_SW) && \
9829+
defined(WC_ASYNC_ENABLE_ECC)
9830+
if (eccKey->nb_ctx != NULL) {
9831+
XFREE(eccKey->nb_ctx, ssl->heap, DYNAMIC_TYPE_TMP_BUFFER);
9832+
}
9833+
#endif
9834+
wc_ecc_free(eccKey);
98229835
XFREE(keyShareEntry->key, ssl->heap, DYNAMIC_TYPE_ECC);
98239836
keyShareEntry->key = NULL;
98249837
}

0 commit comments

Comments
 (0)