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.
This commit is contained in:
Hanno Becker 2018-11-19 11:44:14 +00:00
parent 7390c71609
commit c44e0a4bd1

View File

@ -561,7 +561,7 @@ int main( int argc, char *argv[] )
const char *pers = "ssl_client2"; const char *pers = "ssl_client2";
#if defined(MBEDTLS_USE_PSA_CRYPTO) #if defined(MBEDTLS_USE_PSA_CRYPTO)
psa_key_slot_t slot; psa_key_slot_t slot = 0;
psa_algorithm_t alg = 0; psa_algorithm_t alg = 0;
psa_key_policy_t policy; psa_key_policy_t policy;
psa_status_t status; psa_status_t status;