diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-18 04:31:25 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-26 06:59:42 +0000 |
| commit | 7fd8869c209aa035a0837d179f1e85a3ffb9327e (patch) | |
| tree | e32596fab70dde4fbf73a24e94a011b7b07eb09f /util/nvmutil/nvmutil.c | |
| parent | a3b8f1e8eb85e0ec1df8000d21ea4ae29d87720e (diff) | |
re-add arc4random in nvmutil
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index be5d2f94..0b74e96d 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -195,10 +195,8 @@ main(int argc, char *argv[]) #ifdef NVMUTIL_UNVEIL if (pledge("stdio flock rpath wpath cpath unveil", NULL) == -1) err(errno, "pledge, unveil"); - if (unveil("/dev/urandom", "r") == -1) - err(errno, "unveil: /dev/urandom"); - if (unveil("/dev/random", "r") == -1) - err(errno, "unveil: /dev/random"); + if (unveil("/dev/null", "r") == -1) + err(errno, "unveil: /dev/null"); #else if (pledge("stdio flock rpath wpath cpath", NULL) == -1) err(errno, "pledge"); @@ -989,6 +987,14 @@ hextonum(char ch_s) unsigned long 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; long nr; @@ -1021,6 +1027,7 @@ rlong(void) err(errno, "Incomplete read from random device"); return rval; +#endif } void |
