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 */
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to