summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-14 17:49:18 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-14 17:49:18 +0000
commit01fd54bc1151be9df0bb9019512bf09cc98be89e (patch)
treee9c5bdd465a25111ba2c57f3ff0d76d66b312e7a /util
parentc02dfc4c33ce5c5b4d16f3aeebce97674d088dc4 (diff)
util/nvmutil: prevent overflow in rw_file_exact
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util')
-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;
}