Fix non-PSA TLS 1.3 transform cleanup

Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
This commit is contained in:
Ben Taylor 2026-10-22 10:53:45 +01:00
parent 23370efdea
commit afa648aa44
2 changed files with 9 additions and 3 deletions

View File

@ -1,4 +1,4 @@
Bugfix
* Fix a resource leak in TLS 1.3 transform setup when importing the
decryption traffic key fails after the encryption traffic key has already
been imported. Fixes #10917.
* Fix resource leaks in TLS 1.3 transform setup when a setup step fails
after allocating cipher contexts or importing the encryption traffic key.
Fixes #10917.

View File

@ -977,6 +977,7 @@ int mbedtls_ssl_tls13_populate_transform(
if ((ret = mbedtls_cipher_setup(&transform->cipher_ctx_dec,
cipher_info)) != 0) {
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_cipher_setup", ret);
mbedtls_ssl_transform_free(transform);
return ret;
}
#endif /* MBEDTLS_USE_PSA_CRYPTO */
@ -999,6 +1000,9 @@ int mbedtls_ssl_tls13_populate_transform(
#endif /* MBEDTLS_SSL_CLI_C */
{
/* should not happen */
#if !defined(MBEDTLS_USE_PSA_CRYPTO)
mbedtls_ssl_transform_free(transform);
#endif
return MBEDTLS_ERR_SSL_INTERNAL_ERROR;
}
@ -1010,6 +1014,7 @@ int mbedtls_ssl_tls13_populate_transform(
key_enc, (int) mbedtls_cipher_info_get_key_bitlen(cipher_info),
MBEDTLS_ENCRYPT)) != 0) {
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_cipher_setkey", ret);
mbedtls_ssl_transform_free(transform);
return ret;
}
@ -1017,6 +1022,7 @@ int mbedtls_ssl_tls13_populate_transform(
key_dec, (int) mbedtls_cipher_info_get_key_bitlen(cipher_info),
MBEDTLS_DECRYPT)) != 0) {
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_cipher_setkey", ret);
mbedtls_ssl_transform_free(transform);
return ret;
}
#endif /* MBEDTLS_USE_PSA_CRYPTO */