[PATCH] Fix dangling pointer in commit 99cf026

6 views
Skip to first unread message

Stefano Babic

unread,
Jan 16, 2026, 3:52:41 AMJan 16
to swup...@googlegroups.com, Stefano Babic, Bastian Germann
Change lifetime for pss options in mbedtls_rsa_verify_file because they
are used passed later to the mbedTLS library.

This issue is reported by the gcc compiler:

crypto/swupdate_rsa_verify_mbedtls.c: In function ‘mbedtls_rsa_verify_file’:
crypto/swupdate_rsa_verify_mbedtls.c:92:16: warning: dangling pointer ‘pss_options’ to ‘options’ may be used [-Wdangling-pointer=]
92 | return mbedtls_pk_verify_ext(
| ^~~~~~~~~~~~~~~~~~~~~~
93 | pk_type, pss_options,
| ~~~~~~~~~~~~~~~~~~~~~
94 | &dgst->mbedtls_pk_context, mbedtls_md_get_type(md_info),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
95 | hash_computed, sizeof(hash_computed),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
96 | signature, sizeof(signature)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
97 | );
| ~
crypto/swupdate_rsa_verify_mbedtls.c:64:47: note: ‘options’ declared here
64 | mbedtls_pk_rsassa_pss_options options = {

Signed-off-by: Stefano Babic <stefan...@swupdate.org>
CC: Bastian Germann <ba...@debian.org>
---
crypto/swupdate_rsa_verify_mbedtls.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/crypto/swupdate_rsa_verify_mbedtls.c b/crypto/swupdate_rsa_verify_mbedtls.c
index 3dad1198..7e20d0b3 100644
--- a/crypto/swupdate_rsa_verify_mbedtls.c
+++ b/crypto/swupdate_rsa_verify_mbedtls.c
@@ -59,12 +59,12 @@ static int mbedtls_rsa_verify_file(void *ctx, const char *sigfile,
mbedtls_pk_type_t pk_type = MBEDTLS_PK_RSA;
uint8_t signature[256];
void *pss_options = NULL;
+ mbedtls_pk_rsassa_pss_options options = {
+ .mgf1_hash_id = MBEDTLS_MD_SHA256,
+ .expected_salt_len = MBEDTLS_RSA_SALT_LEN_ANY
+ };
if (get_dgstlib() && !strcmp(get_dgstlib(), MODNAME_PSS)) {
pk_type = MBEDTLS_PK_RSASSA_PSS;
- mbedtls_pk_rsassa_pss_options options = {
- .mgf1_hash_id = MBEDTLS_MD_SHA256,
- .expected_salt_len = MBEDTLS_RSA_SALT_LEN_ANY
- };
pss_options = &options;
}

--
2.43.0

Reply all
Reply to author
Forward
0 new messages