aboutsummaryrefslogtreecommitdiffstats
path: root/sbin/gbde
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2019-02-11 00:11:02 +0000
committerConrad Meyer <cem@FreeBSD.org>2019-02-11 00:11:02 +0000
commit39f37df26e1c6aabf7d47dcdc79fc780e43b4039 (patch)
tree16ee47f68c8eb49e389486f7ec742ecb52ca04df /sbin/gbde
parentf3f08e16a3a8a661dc6b603f7045bc0be18c28e5 (diff)
downloadsrc-39f37df26e1c6aabf7d47dcdc79fc780e43b4039.tar.gz
src-39f37df26e1c6aabf7d47dcdc79fc780e43b4039.zip
gbde(8) - simplify randomisation with arc4random_buf
Submitted by: David CARLIER <devnexen AT gmail.com> Differential Revision: https://reviews.freebsd.org/D18678
Notes
Notes: svn path=/head/; revision=343991
Diffstat (limited to 'sbin/gbde')
-rw-r--r--sbin/gbde/gbde.c13
1 files changed, 1 insertions, 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 */