mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-17 08:40:14 +02:00
util/nvmutil: fix verified first, in prw loop
yes, because otherwise if the offset is still wrong, we allow junk to be written. bad! Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+13
-13
@@ -2086,19 +2086,6 @@ real_pread_pwrite:
|
|||||||
loop_eagain, loop_eintr);
|
loop_eagain, loop_eintr);
|
||||||
|
|
||||||
do {
|
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
|
* Verify again before I/O
|
||||||
* (even with OFF_ERR)
|
* (even with OFF_ERR)
|
||||||
@@ -2119,6 +2106,19 @@ real_pread_pwrite:
|
|||||||
verified = lseek_loop(fd, (off_t)0, SEEK_CUR,
|
verified = lseek_loop(fd, (off_t)0, SEEK_CUR,
|
||||||
loop_eagain, loop_eintr);
|
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 &&
|
} while (r == -1 &&
|
||||||
(errno == try_err(loop_eintr, EINTR)
|
(errno == try_err(loop_eintr, EINTR)
|
||||||
|| errno == try_err(loop_eagain, EAGAIN)));
|
|| errno == try_err(loop_eagain, EAGAIN)));
|
||||||
|
|||||||
Reference in New Issue
Block a user