summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-14 17:47:53 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-26 06:59:41 +0000
commit9ca9b54828daf18819dc72cc631ca45259949436 (patch)
treef18b1cfaf7fcf45525718aea76ee1626eda5eeac
parentb86f415a3e82ffaa08dca4f4006f7cf8c0dfe982 (diff)
util/nvmutil: verify final offset in pwrite/pread
Signed-off-by: Leah Rowe <leah@libreboot.org>
-rw-r--r--util/nvmutil/nvmutil.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 00f45db3..37d7c632 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -1952,6 +1952,7 @@ prw(int fd, void *mem, size_t nrw,
int loop_eagain, int loop_eintr)
{
off_t off_orig;
+ off_t off_last;
ssize_t r;
int saved_errno;
int positional_rw;
@@ -2022,11 +2023,14 @@ real_pread_pwrite:
|| errno == try_err(loop_eagain, EAGAIN)));
saved_errno = errno;
- if (lseek_loop(fd, off_orig, SEEK_SET,
- loop_eagain, loop_eintr) == (off_t)-1) {
+ off_last = lseek_loop(fd, off_orig, SEEK_SET,
+ loop_eagain, loop_eintr);
+ if (off_last == (off_t)-1) {
errno = saved_errno;
return -1;
}
+ if (off_last != off_orig)
+ goto err_prw;
errno = saved_errno;
return rw_over_nrw(r, nrw);