diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-04 01:23:19 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-04 01:23:19 +0000 |
| commit | 7d6f1a6b30db7956fac1261acb6b742895bf506d (patch) | |
| tree | cf96c855af21ebfcba461c32ff057e8da7b64139 | |
| parent | 12778a0ffdb2744a9fd7e4ad2ba6e7c320b4a711 (diff) | |
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>
| -rw-r--r-- | util/nvmutil/nvmutil.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index ea799997..bff8bab0 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -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", |
