mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-17 18:34:57 +02:00
util/nvmutil: stricter i/o errors
Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+10
-6
@@ -1604,10 +1604,11 @@ rw_file_once(int fd, uint8_t *mem, size_t len,
|
|||||||
size_t retries_on_zero = 0;
|
size_t retries_on_zero = 0;
|
||||||
size_t max_retries = 10;
|
size_t max_retries = 10;
|
||||||
|
|
||||||
read_again:
|
if (fd < 0 || !len || len > (size_t)SSIZE_MAX
|
||||||
if ((unsigned int)rw_type > IO_PWRITE)
|
|| (unsigned int)rw_type > IO_PWRITE)
|
||||||
goto err_rw_file_once;
|
goto err_rw_file_once;
|
||||||
|
|
||||||
|
read_again:
|
||||||
rv = do_rw(fd, mem + rc, len - rc, off + rc, rw_type);
|
rv = do_rw(fd, mem + rc, len - rc, off + rc, rw_type);
|
||||||
|
|
||||||
if (rv < 0 && errno == EINTR)
|
if (rv < 0 && errno == EINTR)
|
||||||
@@ -1668,10 +1669,9 @@ prw(int fd, void *mem, size_t nrw,
|
|||||||
|
|
||||||
prw_type = rw_type ^ IO_PREAD;
|
prw_type = rw_type ^ IO_PREAD;
|
||||||
|
|
||||||
if ((unsigned int)prw_type > IO_WRITE) {
|
if (fd < 0 || !nrw || nrw > (size_t)SSIZE_MAX
|
||||||
errno = EIO;
|
|| (unsigned int)prw_type > IO_WRITE)
|
||||||
return -1;
|
goto err_prw;
|
||||||
}
|
|
||||||
|
|
||||||
if ((off_orig = lseek_eintr(fd, (off_t)0, SEEK_CUR)) == (off_t)-1)
|
if ((off_orig = lseek_eintr(fd, (off_t)0, SEEK_CUR)) == (off_t)-1)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1691,6 +1691,10 @@ prw(int fd, void *mem, size_t nrw,
|
|||||||
errno = saved_errno;
|
errno = saved_errno;
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
err_prw:
|
||||||
|
errno = EIO;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static off_t
|
static off_t
|
||||||
|
|||||||
Reference in New Issue
Block a user