util/nvmutil: fix bad bound check

the current check is too liberal. make it sticter.

the issue is that the previous check did not take
into account that it's a check on a uint16_t array,
against nf which refers to a number of bytes.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-02 17:47:58 +00:00
parent 51e4e43c94
commit 589ac92781
+1 -1
View File
@@ -425,7 +425,7 @@ check_bounds(int c, int p)
{
if ((p != 0) && (p != 1))
err(SET_ERR(EINVAL), "check_bounds: invalid partnum %d", p);
if ((c < 0) || (c > nf))
if ((c < 0) || (c > ((nf >> 1) - 1)))
err(SET_ERR(EINVAL), "check_bounds: out of bounds %d", c);
}