Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Dec 2019 04:12:13 +0000 (UTC)
From:      Conrad Meyer <cem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r355692 - head/sbin/fsirand
Message-ID:  <201912130412.xBD4CDZm017850@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cem
Date: Fri Dec 13 04:12:13 2019
New Revision: 355692
URL: https://svnweb.freebsd.org/changeset/base/355692

Log:
  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?

Modified:
  head/sbin/fsirand/fsirand.c

Modified: head/sbin/fsirand/fsirand.c
==============================================================================
--- head/sbin/fsirand/fsirand.c	Fri Dec 13 04:03:05 2019	(r355691)
+++ head/sbin/fsirand/fsirand.c	Fri Dec 13 04:12:13 2019	(r355692)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201912130412.xBD4CDZm017850>