Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Feb 2019 00:11:02 +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: r343991 - head/sbin/gbde
Message-ID:  <201902110011.x1B0B2jE044823@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cem
Date: Mon Feb 11 00:11:02 2019
New Revision: 343991
URL: https://svnweb.freebsd.org/changeset/base/343991

Log:
  gbde(8) - simplify randomisation with arc4random_buf
  
  Submitted by:	David CARLIER <devnexen AT gmail.com>
  Differential Revision:	https://reviews.freebsd.org/D18678

Modified:
  head/sbin/gbde/gbde.c

Modified: head/sbin/gbde/gbde.c
==============================================================================
--- head/sbin/gbde/gbde.c	Sun Feb 10 23:58:56 2019	(r343990)
+++ head/sbin/gbde/gbde.c	Mon Feb 11 00:11:02 2019	(r343991)
@@ -174,18 +174,7 @@ g_read_data(struct g_consumer *cp, off_t offset, off_t
 static void
 random_bits(void *p, u_int len)
 {
-	static int fdr = -1;
-	int i;
-
-	if (fdr < 0) {
-		fdr = open("/dev/urandom", O_RDONLY);
-		if (fdr < 0)
-			err(1, "/dev/urandom");
-	}
-
-	i = read(fdr, p, len);
-	if (i != (int)len)
-		err(1, "read from /dev/urandom");
+	arc4random_buf(p, len);
 }
 
 /* XXX: not nice */



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