diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-18 04:31:25 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-18 04:33:14 +0000 |
| commit | e48a8046d3332d616d8b4f3c6d26cae25f2221f8 (patch) | |
| tree | 4bec2516514cf958d734849eb65f94e7aff7dcf7 /util | |
| parent | 1d1f721d85f079eaeaee7a718228233c7c8a54f7 (diff) | |
re-add arc4random in nvmutil
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util')
| -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 |
