From 5e8683b78dbb5371a8716845fa04c13287816f98 Mon Sep 17 00:00:00 2001 From: cem Date: Mon, 11 Feb 2019 00:11:02 +0000 Subject: [PATCH] gbde(8) - simplify randomisation with arc4random_buf Submitted by: David CARLIER Differential Revision: https://reviews.freebsd.org/D18678 --- sbin/gbde/gbde.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/sbin/gbde/gbde.c b/sbin/gbde/gbde.c index 16afe5e5a489..421242c38c80 100644 --- a/sbin/gbde/gbde.c +++ b/sbin/gbde/gbde.c @@ -174,18 +174,7 @@ g_read_data(struct g_consumer *cp, off_t offset, off_t length, int *error) 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 */