From 1bde9cdf71c62ab5317f1936aa2910b6a2572b6c Mon Sep 17 00:00:00 2001 From: Jaeden Amero Date: Tue, 5 May 2020 10:17:01 +0100 Subject: [PATCH] psa: Clear bits in mbedtls_ecc_group_to_psa() Clear bits in mbedtls_ecc_group_to_psa() to avoid static analyzers and possibly compilers from warning that bits may be used uninitialized in certain code paths. For example, if mbedtls_ecc_group_to_psa() were to be inlined in crypto_extra.h, the following compiler warning is likely. In file included from ../include/psa/crypto.h:3774:0, from ../include/mbedtls/pk.h:49, from pk.c:29: pk.c: In function 'mbedtls_pk_wrap_as_opaque': ../include/psa/crypto_struct.h:460:33: error: 'bits' may be used uninitialized in this function [-Werror=maybe-uninitialized] attributes->core.bits = (psa_key_bits_t) bits; ^~~~~~~~~~~~~~~~~~~~~ pk.c:608:12: note: 'bits' was declared here size_t bits; ^~~~ Signed-off-by: Jaeden Amero --- library/psa_crypto.c | 1 + 1 file changed, 1 insertion(+) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 733a2e46c..0ac629098 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -420,6 +420,7 @@ psa_ecc_curve_t mbedtls_ecc_group_to_psa( mbedtls_ecp_group_id grpid, *bits = 448; return( PSA_ECC_CURVE_MONTGOMERY ); default: + *bits = 0; return( 0 ); } }