summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2022-12-08 21:20:53 +0000
committerLeah Rowe <leah@libreboot.org>2022-12-08 21:20:53 +0000
commit27876c6421b5eb1f318688a38698f3c2067131a8 (patch)
tree648f99e52b1249f5495c63f6811b18b57b773415
parent960af2d6e8d882d958d25333e7cab864877e37b5 (diff)
util/nvmutil: return error when fstat() is -1
Another oversight in my error handling.
-rw-r--r--util/nvmutil/nvmutil.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 759edea0..ef0a71e6 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -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;