mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-24 21:54:11 +02:00
util/nvmutil: return error when fstat() is -1
Another oversight in my error handling.
This commit is contained in:
@@ -143,7 +143,8 @@ readFromFile(int *fd, uint8_t *buf, const char *path, int flags, size_t size)
|
|||||||
} else if (((*fd) = open(path, flags)) == -1) {
|
} else if (((*fd) = open(path, flags)) == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (size == SIZE_8KB) {
|
} else if (size == SIZE_8KB) {
|
||||||
fstat((*fd), &st);
|
if (fstat((*fd), &st) == -1)
|
||||||
|
return -1;
|
||||||
if ((st.st_size != SIZE_8KB) && strcmp(path, "/dev/urandom")) {
|
if ((st.st_size != SIZE_8KB) && strcmp(path, "/dev/urandom")) {
|
||||||
fprintf(stderr, "Bad file size\n");
|
fprintf(stderr, "Bad file size\n");
|
||||||
errno = ECANCELED;
|
errno = ECANCELED;
|
||||||
|
|||||||
Reference in New Issue
Block a user