summaryrefslogtreecommitdiff
path: root/util/libreboot-utils/lib
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-25 20:49:10 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-26 06:59:42 +0000
commit4034b211ce7ec21f7db167755e84265232061b1f (patch)
tree7658bb911af99e3a7f8c17999ba90c8f2d56fcbf /util/libreboot-utils/lib
parentb26837c4dcbe8b4c0747d423380b25715d638747 (diff)
lbutils, rset: err if zero bytes requested
similar to the logic about other failure states Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/libreboot-utils/lib')
-rw-r--r--util/libreboot-utils/lib/rand.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/util/libreboot-utils/lib/rand.c b/util/libreboot-utils/lib/rand.c
index 5c6cc562..bb142bdc 100644
--- a/util/libreboot-utils/lib/rand.c
+++ b/util/libreboot-utils/lib/rand.c
@@ -64,6 +64,10 @@ rset(void *buf, size_t n)
if (if_err(buf == NULL, EFAULT))
goto err;
+ if (n == 0)
+ err_no_cleanup(0, EPERM,
+ "rset: zero-byte length request");
+
#if (defined(__OpenBSD__) || defined(__FreeBSD__) || \
defined(__NetBSD__) || defined(__APPLE__) || \
defined(__DragonFly__)) && !(defined(USE_URANDOM) && \
@@ -113,7 +117,7 @@ out:
errno = saved_errno;
return;
err:
- err_no_cleanup(1, ECANCELED,
+ err_no_cleanup(0, ECANCELED,
"Randomisation failure, possibly unsupported in your kernel");
exit(EXIT_FAILURE);
}