diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-25 20:49:10 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-25 20:49:10 +0000 |
| commit | 7c0f6c160f9e15393fe2786262b3e1fca4d4ce94 (patch) | |
| tree | 165248294912cbb443fd8d9777945e71c5d8d9f8 /util/libreboot-utils/lib | |
| parent | 51e8b6244234fc99d72b556cd0bdf3bbbe4c7cb8 (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.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); } |
