diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-06 19:40:28 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-06 19:40:28 +0000 |
| commit | fb805caf6a62a5b0f9fd0c8183b8e6eed7b46bc5 (patch) | |
| tree | e7a6f8eabc4b28a143877a165952517f2b26243f /util/nvmutil/nvmutil.c | |
| parent | f316701d74cdb7e446cf560b70b1af62c3773f22 (diff) | |
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>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index dfdbac20..9c8f678a 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -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); |
