lbutils, rset: err if zero bytes requested

similar to the logic about other failure states

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-25 20:49:10 +00:00
parent b26837c4dc
commit 4034b211ce
+5 -1
View File
@@ -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);
}