util/libreboot-utils: fix div by zero in rsize

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-27 17:14:10 +00:00
parent db6e817ded
commit 0cc4ff7b3b
+3
View File
@@ -83,6 +83,9 @@ size_t
rsize(size_t n)
{
size_t rval = SIZE_MAX;
if (!n)
err_no_cleanup(0, EFAULT, "rsize: division by zero");
for (; rval >= SIZE_MAX - (SIZE_MAX % n); rset(&rval, sizeof(rval)));
return rval % n;