util/nvmutil rhex: check against sizeof(rnum)

checking against -1 is incorrect, because we specifically want
to ensure that it always read the number of bytes defined by
the size of rnum.

this still covers the case where the return value is -1, and
therefore makes the error handling much stricter.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-03 19:00:14 +00:00
parent 4775bb2348
commit 668dec36e9
+1 -1
View File
@@ -368,7 +368,7 @@ rhex(void)
if (!n) {
n = sizeof(rnum) - 1;
err_if(read(rfd, (uint8_t *) &rnum, n + 1) == -1);
err_if(read(rfd, (uint8_t *) &rnum, n + 1) != sizeof(rnum));
}
return rnum[n--] & 0xf;