mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-03-25 13:29:03 +02:00
util/nvmutil: rw_file_exact: check inputs also
we check them in prw, but we used to rely on prw because we called that first. no more. it's correct to also check them here anyway, in case i ever call another function here. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -1888,6 +1888,16 @@ rw_file_exact(int fd, u8 *mem, size_t nrw,
|
||||
size_t nrw_cur;
|
||||
void *mem_cur;
|
||||
|
||||
if (mem == NULL)
|
||||
goto err_rw_file_exact;
|
||||
|
||||
if (fd < 0
|
||||
|| off < 0
|
||||
|| !nrw /* prevent zero read request */
|
||||
|| nrw > (size_t)SSIZE_MAX /* prevent overflow */
|
||||
|| (uint)rw_type > IO_PWRITE)
|
||||
goto err_rw_file_exact;
|
||||
|
||||
while (1) {
|
||||
|
||||
/* Prevent theoretical overflow */
|
||||
|
||||
Reference in New Issue
Block a user