From ab9ee73350d12429a122101b15ef677c39a9e8dc Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 12 Mar 2026 16:34:33 +0000 Subject: util/nvmutil: mitigate buggy libc i/o Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'util/nvmutil') diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 240cb73d..8448edc0 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -1480,6 +1480,12 @@ read_again: * cause an overflow. Specifications guarantee * this won't happen, but spec != implementation */ + if ((size_t)rv > SSIZE_MAX) { + errno = EIO; + return -1; + /* we will not tolerate your buggy libc */ + } + if ((size_t)rv > (len - rc) /* Prevent overflow */ || rv == 0) { /* Prevent infinite 0-byte loop */ if (rv == 0) { -- cgit v1.2.1