Skip to content

Commit

Permalink
gbde(8) - simplify randomisation with arc4random_buf
Browse files Browse the repository at this point in the history
Submitted by:	David CARLIER <devnexen AT gmail.com>
Differential Revision:	https://reviews.freebsd.org/D18678
  • Loading branch information
cemeyer committed Feb 11, 2019
1 parent f3f08e1 commit 39f37df
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions sbin/gbde/gbde.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 39f37df

Please sign in to comment.