mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-03-25 13:29:03 +02:00
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>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user