diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-13 17:39:48 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-26 06:59:41 +0000 |
| commit | 5f8593b5810809b0694fa28e29fdddee474c4fd8 (patch) | |
| tree | f9fc5740c80d97afdff07ac90b757408de087360 /util/nvmutil/nvmutil.c | |
| parent | 6ad09f55e02f5f3c20c164b3a62b2e2b0e03cccd (diff) | |
util/nvmutil: fix offset validation
i didn't take into account partial writes, in io_args
this fixes it
unfortunately, this means i have to loosen the offset
check a bit, but it's fine
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 7fdb8545..f586e199 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -1753,18 +1753,15 @@ static int io_args(int fd, void *mem, size_t nrw, off_t off, int rw_type) { - if (mem != pad + if (mem != (void *)pad && mem != rnum && (mem < (void *)buf || mem >= (void *)(buf + GBE_FILE_SIZE))) goto err_io_args; - if (off != 0 - && off != gbe_file_offset(1, "i/o check")) + if (off < 0 || off >= gbe_file_size) goto err_io_args; - if (nrw != GBE_PART_SIZE && - nrw != NVM_SIZE && - nrw != NUM_RANDOM_BYTES) + if (nrw > GBE_PART_SIZE) goto err_io_args; if (fd < 0 |
