diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-25 20:49:10 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-26 06:59:42 +0000 |
| commit | 4034b211ce7ec21f7db167755e84265232061b1f (patch) | |
| tree | 7658bb911af99e3a7f8c17999ba90c8f2d56fcbf | |
| parent | b26837c4dcbe8b4c0747d423380b25715d638747 (diff) | |
lbutils, rset: err if zero bytes requested
similar to the logic about other failure states
Signed-off-by: Leah Rowe <leah@libreboot.org>
| -rw-r--r-- | util/libreboot-utils/lib/rand.c | 6 |
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); } |
