diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-15 02:14:23 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-15 02:14:23 +0000 |
| commit | f03ca35497b3eece2e1c2c2310fe6dd6cc8eb130 (patch) | |
| tree | fe679a9e5ebf51c83493971397c791e3368a6ca5 | |
| parent | fdf2e68163f17d5441484d543d78d0bb0a2bb573 (diff) | |
yes, because otherwise if the offset is still
wrong, we allow junk to be written. bad!
Signed-off-by: Leah Rowe <leah@libreboot.org>
| -rw-r--r-- | util/nvmutil/nvmutil.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 4cc35505..fe8364f7 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -2086,19 +2086,6 @@ real_pread_pwrite: loop_eagain, loop_eintr); do { - if (off != verified) - goto err_prw; - - if (rw_type == IO_PREAD) - r = read(fd, mem, nrw); - else if (rw_type == IO_PWRITE) - r = write(fd, mem, nrw); - - if (rw_over_nrw(r, nrw) == -1) { - errno = EIO; - break; - } - /* * Verify again before I/O * (even with OFF_ERR) @@ -2119,6 +2106,19 @@ real_pread_pwrite: verified = lseek_loop(fd, (off_t)0, SEEK_CUR, loop_eagain, loop_eintr); + if (off != verified) + goto err_prw; + + if (rw_type == IO_PREAD) + r = read(fd, mem, nrw); + else if (rw_type == IO_PWRITE) + r = write(fd, mem, nrw); + + if (rw_over_nrw(r, nrw) == -1) { + errno = EIO; + break; + } + } while (r == -1 && (errno == try_err(loop_eintr, EINTR) || errno == try_err(loop_eagain, EAGAIN))); |
