From 01fd54bc1151be9df0bb9019512bf09cc98be89e Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 14 Mar 2026 17:49:18 +0000 Subject: util/nvmutil: prevent overflow in rw_file_exact Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 4 ++++ 1 file changed, 4 insertions(+) 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; } -- cgit v1.2.1