mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-19 19:23:24 +02:00
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:
@@ -299,6 +299,9 @@ read_gbe_part(int p, int invert)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (errno)
|
||||||
|
err(errno, "Unhandled error on read of file '%s'", fname);
|
||||||
|
|
||||||
swap(p ^ invert); /* handle big-endian host CPU */
|
swap(p ^ invert); /* handle big-endian host CPU */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -420,16 +423,17 @@ read_urandom(uint8_t *rnum, size_t rsize)
|
|||||||
rsize, retry, "read"))
|
rsize, retry, "read"))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (errno)
|
||||||
|
err(errno, "Unhandled error on read of file '/dev/urandom'");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
check_read_or_die(const char *rpath, ssize_t rval, size_t rsize,
|
check_read_or_die(const char *rpath, ssize_t rval, size_t rsize,
|
||||||
int retry, const char *readtype)
|
int retry, const char *readtype)
|
||||||
{
|
{
|
||||||
if (rval == (ssize_t) rsize) {
|
if (rval == (ssize_t) rsize)
|
||||||
errno = 0;
|
|
||||||
return 1; /* Successful read */
|
return 1; /* Successful read */
|
||||||
}
|
|
||||||
|
|
||||||
if (rval != -1)
|
if (rval != -1)
|
||||||
err(ECANCELED, "Short %s, %zd bytes, on file: %s",
|
err(ECANCELED, "Short %s, %zd bytes, on file: %s",
|
||||||
|
|||||||
Reference in New Issue
Block a user