gbde(8) - simplify randomisation with arc4random_buf

Submitted by:	David CARLIER <devnexen AT gmail.com>
Differential Revision:	https://reviews.freebsd.org/D18678
This commit is contained in:
cem 2019-02-11 00:11:02 +00:00
parent 955ed771da
commit 5e8683b78d

View File

@ -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 */