libreboot-utils: tidy up rand

also re-add /dev/urandom support, as a config option

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-25 17:52:53 +00:00
parent 6c8cf9a9e0
commit 00b56c0278
3 changed files with 40 additions and 82 deletions
+5 -4
View File
@@ -903,11 +903,12 @@ mkhtemp_fill_random(char *p, size_t xc)
for (chx = 0; chx < xc; chx++) {
retry_rand:
/* on bsd: uses arc4random
on linux: uses getrandom
*never returns error*
/* /dev/urandom if enabled, OR:
* on bsd: uses arc4random
* on linux: uses getrandom
NOTE: *aborts* on error, regardless of method
*/
r = rlong(); /* always returns successful */
r = rlong(); /* always *returns* successfully */
if (r >= limit)
goto retry_rand;