mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-16 13:16:47 +02:00
util/nvmutil: fix EINTR detection on urandom read
i forgot to handle it in the previous refactor not really a problem in practise, since the first read probably succeeds anyway. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+11
-4
@@ -992,10 +992,17 @@ read_dev_urandom(int fd, void *buf, size_t len)
|
|||||||
for (retry = 0; retry < MAX_RETRY_RW; retry++) {
|
for (retry = 0; retry < MAX_RETRY_RW; retry++) {
|
||||||
rval = read(fd, buf, len);
|
rval = read(fd, buf, len);
|
||||||
|
|
||||||
if (rval && (size_t)rval <= len) {
|
if (rval == -1) {
|
||||||
errno = 0;
|
if (errno == EINTR)
|
||||||
return rval;
|
continue;
|
||||||
|
err(errno, "%s", rname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!rval || (size_t)rval > len)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
err(EINTR, "%s: read: max retries exceeded: %s", rname);
|
err(EINTR, "%s: read: max retries exceeded: %s", rname);
|
||||||
@@ -1228,7 +1235,7 @@ write_gbe_file_part(size_t p)
|
|||||||
|
|
||||||
if (rval != -1)
|
if (rval != -1)
|
||||||
err(ECANCELED,
|
err(ECANCELED,
|
||||||
"%s: Short pwrite, %zd bytes",
|
"%s: Short pwrite of %zd bytes",
|
||||||
fname, rval);
|
fname, rval);
|
||||||
|
|
||||||
if (errno != EINTR)
|
if (errno != EINTR)
|
||||||
|
|||||||
Reference in New Issue
Block a user