summaryrefslogtreecommitdiff
path: root/util/libreboot-utils
diff options
context:
space:
mode:
Diffstat (limited to 'util/libreboot-utils')
-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);
}