summaryrefslogtreecommitdiff
path: root/util/nvmutil/nvmutil.c
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-06 19:23:56 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-06 19:23:56 +0000
commit9095722079730c36c8d9fd627a7ea7580a2354c1 (patch)
tree08524ef133d868c82cf4edb71a4297791c014bc4 /util/nvmutil/nvmutil.c
parent1131240d0208e88db7443d57c195360584929c66 (diff)
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>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
-rw-r--r--util/nvmutil/nvmutil.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 6b2528f5..30bad1d5 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -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);