mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-18 14:12:44 +02:00
util/nvmutil: fix offset validation
i didn't take into account partial writes, in io_args this fixes it unfortunately, this means i have to loosen the offset check a bit, but it's fine Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -1753,18 +1753,15 @@ static int
|
|||||||
io_args(int fd, void *mem, size_t nrw,
|
io_args(int fd, void *mem, size_t nrw,
|
||||||
off_t off, int rw_type)
|
off_t off, int rw_type)
|
||||||
{
|
{
|
||||||
if (mem != pad
|
if (mem != (void *)pad
|
||||||
&& mem != rnum
|
&& mem != rnum
|
||||||
&& (mem < (void *)buf || mem >= (void *)(buf + GBE_FILE_SIZE)))
|
&& (mem < (void *)buf || mem >= (void *)(buf + GBE_FILE_SIZE)))
|
||||||
goto err_io_args;
|
goto err_io_args;
|
||||||
|
|
||||||
if (off != 0
|
if (off < 0 || off >= gbe_file_size)
|
||||||
&& off != gbe_file_offset(1, "i/o check"))
|
|
||||||
goto err_io_args;
|
goto err_io_args;
|
||||||
|
|
||||||
if (nrw != GBE_PART_SIZE &&
|
if (nrw > GBE_PART_SIZE)
|
||||||
nrw != NVM_SIZE &&
|
|
||||||
nrw != NUM_RANDOM_BYTES)
|
|
||||||
goto err_io_args;
|
goto err_io_args;
|
||||||
|
|
||||||
if (fd < 0
|
if (fd < 0
|
||||||
|
|||||||
Reference in New Issue
Block a user