lib: parameter check in hash_calculate
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Tue, 22 Aug 2023 09:10:20 +0000 (11:10 +0200)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sun, 27 Aug 2023 06:21:07 +0000 (08:21 +0200)
commiteb48efce260aefc0eceec90bd4d9adcd881f1b14
treed85e74bf4a848f5044fd2ebed1bccb81fd7f83e2
parente508b930021168c788f14977fc101ccc1151b3c8
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>
lib/hash-checksum.c