util/nvmutil: calculate off AFTER part validation

because we check the part first, so we need to know it's
valid before proceeding.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-06 19:23:56 +00:00
parent 1131240d02
commit 9095722079
+3 -1
View File
@@ -807,12 +807,14 @@ static off_t
gbe_x_offset(size_t p, const char *f_op, const char *d_type,
off_t nsize, off_t ncmp)
{
off_t off = (off_t)p * nsize;
off_t off;
if (p > 1)
err(ECANCELED, "GbE %s %s invalid partnum: %s",
d_type, f_op, fname);
off = (off_t)p * nsize;
if (off + GBE_PART_SIZE > ncmp)
err(ECANCELED, "GbE %s %s out of bounds: %s",
d_type, f_op, fname);