summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2025-01-27 04:57:32 +0000
committerLeah Rowe <leah@libreboot.org>2025-01-27 04:57:32 +0000
commit906071083306722e43cd5d3c0bdf2fc2ad3b69c8 (patch)
treeab77adf8e0ae2430acbdd0844238e322b6731f97
parentc72f699d368e88dcfc48316fae8b1f16393d3d9f (diff)
util/nvmutil: err if bytes read lower than nf
same as the last change. just covering edge cases. we will likely never trigger this error. Signed-off-by: Leah Rowe <leah@libreboot.org>
-rw-r--r--util/nvmutil/nvmutil.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 15090a5a..13fce715 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -225,7 +225,13 @@ readGbe(void)
if (!do_read[p])
continue; /* avoid unnecessary reads */
- err_if(pread(fd, (uint8_t *) gbe[p], nf, p * partsize) == -1);
+ ssize_t nr = pread(fd, (uint8_t *) gbe[p], nf, p * partsize);
+ err_if(nr == -1);
+ if (nr != nf)
+ err(errno == ECANCELED,
+ "%ld bytes written on '%s', expected %ld bytes\n",
+ nr, filename, nf);
+
swap(p); /* handle big-endian host CPU */
}
}