From 9095722079730c36c8d9fd627a7ea7580a2354c1 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Fri, 6 Mar 2026 19:23:56 +0000 Subject: 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 --- util/nvmutil/nvmutil.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); -- cgit v1.2.1