From e28409d80b65da73cd9fa4d5564bdb8cf3b2d991 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Wed, 4 Mar 2026 01:27:13 +0000 Subject: util/nvmutil: handle error after check_read_or_die we already exit reliably in that function. the current code is logically correct, but very weak against future changes. this extra check is essentially redundant, but prevantative against future changes. Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'util/nvmutil') diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index bff8bab0..6cb11d55 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -301,6 +301,8 @@ read_gbe_part(int p, int invert) if (errno) err(errno, "Unhandled error on read of file '%s'", fname); + if (rval != (ssize_t) SIZE_4KB) + err(ECANCELED, "Unknown error on read of file '%s'", fname); swap(p ^ invert); /* handle big-endian host CPU */ } @@ -426,6 +428,8 @@ read_urandom(uint8_t *rnum, size_t rsize) if (errno) err(errno, "Unhandled error on read of file '/dev/urandom'"); + if (rval != (ssize_t) rsize) + err(ECANCELED, "Unknown error on read of file '/dev/urandom'"); } static int -- cgit v1.2.1