mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 14:02:52 +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++) {
|
||||
rval = read(fd, buf, len);
|
||||
|
||||
if (rval && (size_t)rval <= len) {
|
||||
errno = 0;
|
||||
return rval;
|
||||
if (rval == -1) {
|
||||
if (errno == EINTR)
|
||||
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);
|
||||
@@ -1228,7 +1235,7 @@ write_gbe_file_part(size_t p)
|
||||
|
||||
if (rval != -1)
|
||||
err(ECANCELED,
|
||||
"%s: Short pwrite, %zd bytes",
|
||||
"%s: Short pwrite of %zd bytes",
|
||||
fname, rval);
|
||||
|
||||
if (errno != EINTR)
|
||||
|
||||
Reference in New Issue
Block a user