summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-14 17:49:18 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-26 06:59:41 +0000
commitb231e28c939e2b32fec23d7928a9136e574242c1 (patch)
tree52d950d90d974ddd65af08b56daaac9c4592194a
parent9ca9b54828daf18819dc72cc631ca45259949436 (diff)
util/nvmutil: prevent overflow in rw_file_exact
Signed-off-by: Leah Rowe <leah@libreboot.org>
-rw-r--r--util/nvmutil/nvmutil.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 37d7c632..2d602038 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -1860,6 +1860,10 @@ rw_file_exact(int fd, u8 *mem, size_t nrw,
return -1;
}
+ /* Prevent theoretical overflow */
+ if (rv > nrw - rc)
+ goto err_rw_file_exact;
+
rc += (size_t)rv;
}