diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-15 01:06:36 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-15 01:06:36 +0000 |
| commit | f509c87d045654269cc1692a209d7213d673c1dc (patch) | |
| tree | 2a075d8a211469db7ad782a18f5998ff9d4312c0 /util/nvmutil | |
| parent | 7bd1e551d8680e782361742840fee372f6fb068a (diff) | |
util/nvmutil: prevent underflow in comparison
we already check before that rv is not negative,
and it starts at zero, but it's good to guard
it here just in case (for future re-factoring).
if rv is negative, it could convert (casted to
size_t) to a huge number (we don't want that).
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 2d613f81..d05d25ce 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -1908,7 +1908,7 @@ rw_file_exact(int fd, u8 *mem, size_t nrw, while (1) { /* Prevent theoretical overflow */ - if ((size_t)rv > (nrw - rc)) + if (rv >= 0 && (size_t)rv > (nrw - rc)) goto err_rw_file_exact; rc += rv; |
