From 229fd29f46596c4f3dbb92063cf4e89b7c148c00 Mon Sep 17 00:00:00 2001 From: cem Date: Fri, 13 Dec 2019 04:12:13 +0000 Subject: [PATCH] fsirand(8): Just use arc4random(3) Remove single use of dubious srandomdev(3) + random(3) and replace with arc4random(3), as is used already in this program. Follow-up question: Do we really need this program anymore? In base? --- sbin/fsirand/fsirand.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sbin/fsirand/fsirand.c b/sbin/fsirand/fsirand.c index f24d34705b72..48ffcbaf0665 100644 --- a/sbin/fsirand/fsirand.c +++ b/sbin/fsirand/fsirand.c @@ -83,8 +83,6 @@ main(int argc, char *argv[]) if (argc - optind < 1) usage(); - srandomdev(); - /* Increase our data size to the max */ if (getrlimit(RLIMIT_DATA, &rl) == 0) { rl.rlim_cur = rl.rlim_max; @@ -167,7 +165,7 @@ fsirand(char *device) if (!printonly) { /* Randomize fs_id and write out new sblock and backups */ sblock->fs_id[0] = (u_int32_t)time(NULL); - sblock->fs_id[1] = random(); + sblock->fs_id[1] = arc4random(); if (sbput(devfd, sblock, sblock->fs_ncg) != 0) { warn("could not write updated superblock"); return (1);