util/nvmutil: return error when fstat() is -1

Another oversight in my error handling.
fsdg20230625
Leah Rowe 2022-12-08 21:20:53 +00:00
parent 960af2d6e8
commit 27876c6421
1 changed files with 2 additions and 1 deletions

View File

@ -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) {
return -1;
} 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")) {
fprintf(stderr, "Bad file size\n");
errno = ECANCELED;