summaryrefslogtreecommitdiff
path: root/util/libreboot-utils
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-26 08:59:03 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-26 08:59:03 +0000
commitd6087901c107d45123a57d5fc905314aac7969c7 (patch)
treeea2764930590ca330f62e9460242a32fa39b34ee /util/libreboot-utils
parentcf16d07df97b8fbec9fe17b3f437ffc297af9ed2 (diff)
rand/libreboot/utils: prevent div by zero
not really a thing. bufsiz would never be zero, unless the demon takes over linux Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/libreboot-utils')
-rw-r--r--util/libreboot-utils/lib/rand.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/util/libreboot-utils/lib/rand.c b/util/libreboot-utils/lib/rand.c
index 06d5f49e..3b20ab65 100644
--- a/util/libreboot-utils/lib/rand.c
+++ b/util/libreboot-utils/lib/rand.c
@@ -72,6 +72,12 @@
* or your program dies.
*/
+#ifndef BUFSIZ
+#define BUFSIZ 8192 /* reasonably on modern 64-bit systems */
+#elif (BUFSIZ <= 0)
+#error defined buffer size BUFSIZ below or equal to zero
+#endif
+
int
win_lottery(char **buf) /* are u lucky? */
{