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-14 17:47:53 +0000
commitc02dfc4c33ce5c5b4d16f3aeebce97674d088dc4 (patch)
treea1e58e4954604a02198cb2294304caa71ac200d8
parent276b9d34e84bb7613ae3765a439a6f993d6d2854 (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);