re-add arc4random in nvmutil

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-18 04:31:25 +00:00
parent a3b8f1e8eb
commit 7fd8869c20
+11 -4
View File
@@ -195,10 +195,8 @@ main(int argc, char *argv[])
#ifdef NVMUTIL_UNVEIL #ifdef NVMUTIL_UNVEIL
if (pledge("stdio flock rpath wpath cpath unveil", NULL) == -1) if (pledge("stdio flock rpath wpath cpath unveil", NULL) == -1)
err(errno, "pledge, unveil"); err(errno, "pledge, unveil");
if (unveil("/dev/urandom", "r") == -1) if (unveil("/dev/null", "r") == -1)
err(errno, "unveil: /dev/urandom"); err(errno, "unveil: /dev/null");
if (unveil("/dev/random", "r") == -1)
err(errno, "unveil: /dev/random");
#else #else
if (pledge("stdio flock rpath wpath cpath", NULL) == -1) if (pledge("stdio flock rpath wpath cpath", NULL) == -1)
err(errno, "pledge"); err(errno, "pledge");
@@ -989,6 +987,14 @@ hextonum(char ch_s)
unsigned long unsigned long
rlong(void) rlong(void)
{ {
#if defined(__OpenBSD__) || defined(__FreeBSD__) || \
defined(__NetBSD__) || defined(__APPLE__)
unsigned long rval;
arc4random_buf(&rval, sizeof(unsigned long);
return rval;
#else
int fd; int fd;
long nr; long nr;
@@ -1021,6 +1027,7 @@ rlong(void)
err(errno, "Incomplete read from random device"); err(errno, "Incomplete read from random device");
return rval; return rval;
#endif
} }
void void