diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-14 17:49:18 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-26 06:59:41 +0000 |
| commit | b231e28c939e2b32fec23d7928a9136e574242c1 (patch) | |
| tree | 52d950d90d974ddd65af08b56daaac9c4592194a | |
| parent | 9ca9b54828daf18819dc72cc631ca45259949436 (diff) | |
util/nvmutil: prevent overflow in rw_file_exact
Signed-off-by: Leah Rowe <leah@libreboot.org>
| -rw-r--r-- | util/nvmutil/nvmutil.c | 4 |
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; } |
