summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-27 17:14:10 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-27 17:14:10 +0000
commit0cc4ff7b3b732362ee2332669be415a6a1e1d75e (patch)
treea1b7cf050d8bd38fc60610d30ce14eae09400f56
parentdb6e817ded9f99cb4d153ba91f7688874d8c67a1 (diff)
util/libreboot-utils: fix div by zero in rsizeHEADmaster
Signed-off-by: Leah Rowe <leah@libreboot.org>
-rw-r--r--util/libreboot-utils/lib/rand.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/util/libreboot-utils/lib/rand.c b/util/libreboot-utils/lib/rand.c
index 3155eec3..4c7458c7 100644
--- a/util/libreboot-utils/lib/rand.c
+++ b/util/libreboot-utils/lib/rand.c
@@ -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;