util/nvmutil: extra part check in set_checksum

it calls word() anyway, but we should still check it here,
since this is quite a critical function.

the other bound checks are done by word(), which this
function uses to add everything up.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-06 19:40:28 +00:00
parent f316701d74
commit fb805caf6a
+3
View File
@@ -617,6 +617,9 @@ set_checksum(size_t p)
size_t c;
uint16_t val16 = 0;
if (p > 1)
err(ECANCELED, "Bad part num %zu (must be 0 or 1)", p);
for (c = 0; c < NVM_CHECKSUM_WORD; c++)
val16 += word(c, p);