Skip to contentSkip to conversation

rsa: check that pointer checksum isn't NULL before using it

PATCH In review Philippe Reynes 3 participants 3 messages Mar 19, 2019 – Mar 25, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rsa: check that pointer checksum isn't NULL before using it

The pointer checksum were used before checking that it isn't NULL. We move the code that use it after the check.

Reported-by Coverity (CID: 185835)
---
 lib/rsa/rsa-verify.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/rsa/rsa-verify.c +2 -1
index 9734f6d..287fcc4 100644
@@ -295,7 +295,7 @@ static int rsa_verify_key(struct image_sign_info *info,
 #endif
 	struct checksum_algo *checksum = info->checksum;
 	struct padding_algo *padding = info->padding;
-	int hash_len = checksum->checksum_len;
+	int hash_len;
 
 	if (!prop || !sig || !hash || !checksum)
 		return -EIO;
@@ -315,6 +315,7 @@ static int rsa_verify_key(struct image_sign_info *info,
 	}
 
 	uint8_t buf[sig_len];
+	hash_len = checksum->checksum_len;
 
 #if !defined(USE_HOSTCC)
 	ret = uclass_get_device(UCLASS_MOD_EXP, 0, &mod_exp_dev);
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 rsa: check that pointer checksum isn't NULL before using it

Quoted 9 lines · Philippe Reynes

The pointer checksum were used before checking that it isn't NULL. We move the code that use it after the check.

Reported-by Coverity (CID: 185835)
---
 lib/rsa/rsa-verify.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
#2 lore raw
In reply to Philippe Reynes
Quoted 6 lines · Philippe Reynes

The pointer checksum were used before checking that it isn't NULL. We move the code that use it after the check.

Reported-by Coverity (CID: 185835)

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190325/934180bb/attachment.sig>