From 27876c6421b5eb1f318688a38698f3c2067131a8 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 8 Dec 2022 21:20:53 +0000 Subject: util/nvmutil: return error when fstat() is -1 Another oversight in my error handling. --- util/nvmutil/nvmutil.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; -- cgit v1.2.1