util/nvmutil: handle errno after file read

errno shouldn't be set, after reading a file successfully.

if it is, that's a bug. handle it accordingly.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-04 01:23:19 +00:00
parent 12778a0ffd
commit 7d6f1a6b30
+7 -3
View File
@@ -299,6 +299,9 @@ read_gbe_part(int p, int invert)
break;
}
if (errno)
err(errno, "Unhandled error on read of file '%s'", fname);
swap(p ^ invert); /* handle big-endian host CPU */
}
@@ -420,16 +423,17 @@ read_urandom(uint8_t *rnum, size_t rsize)
rsize, retry, "read"))
break;
}
if (errno)
err(errno, "Unhandled error on read of file '/dev/urandom'");
}
static int
check_read_or_die(const char *rpath, ssize_t rval, size_t rsize,
int retry, const char *readtype)
{
if (rval == (ssize_t) rsize) {
errno = 0;
if (rval == (ssize_t) rsize)
return 1; /* Successful read */
}
if (rval != -1)
err(ECANCELED, "Short %s, %zd bytes, on file: %s",