From c44e0a4bd1d39655bd70097a4b8b7e22f8bf7a26 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 19 Nov 2018 11:44:14 +0000 Subject: [PATCH] Initialize PSA key slot as invalid in ssl_client2.c Otherwise, if `mbedtls_psa_get_free_key_slot()` fails to find a fresh key slot, the slot value will be undefined, and the call to `psa_destroy_key()` at the end of `main()` is undefined behavior. --- programs/ssl/ssl_client2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 1bf6e2f0c..ff625fbd2 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -561,7 +561,7 @@ int main( int argc, char *argv[] ) const char *pers = "ssl_client2"; #if defined(MBEDTLS_USE_PSA_CRYPTO) - psa_key_slot_t slot; + psa_key_slot_t slot = 0; psa_algorithm_t alg = 0; psa_key_policy_t policy; psa_status_t status;