summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2023-08-22 12:10:20 +0300
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2023-08-27 09:21:07 +0300
commiteb48efce260aefc0eceec90bd4d9adcd881f1b14 (patch)
treed85e74bf4a848f5044fd2ebed1bccb81fd7f83e2
parente508b930021168c788f14977fc101ccc1151b3c8 (diff)
downloadu-boot-eb48efce260aefc0eceec90bd4d9adcd881f1b14.tar.xz
lib: parameter check in hash_calculate
If hash_calculate is invoked with region_count = 0, it will try to hash INT_MAX regions. We should check this parameter. * Avoid a comparison with different signedness. * Check that region_count is at least 1. * Avoid a superfluous assignment. Fixes: b37b46f042cc ("rsa: Use checksum algorithms from struct hash_algo") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--lib/hash-checksum.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/hash-checksum.c b/lib/hash-checksum.c
index 8f2a42f9a0..68c290d64d 100644
--- a/lib/hash-checksum.c
+++ b/lib/hash-checksum.c
@@ -23,8 +23,10 @@ int hash_calculate(const char *name,
struct hash_algo *algo;
int ret = 0;
void *ctx;
- uint32_t i;
- i = 0;
+ int i;
+
+ if (region_count < 1)
+ return -EINVAL;
ret = hash_progressive_lookup_algo(name, &algo);
if (ret)