diff options
author | tb <tb@cvs.openbsd.org> | 2015-12-07 07:40:48 +0000 |
---|---|---|
committer | tb <tb@cvs.openbsd.org> | 2015-12-07 07:40:48 +0000 |
commit | 403489d4a2346ec2e013afe2ef03797a31864529 (patch) | |
tree | 0112ce2fc4d88b88df3808b4a8c6f28aa0606367 /sbin/dhclient | |
parent | 815d109977c344b64ad7a5f2f5eae3df2ecb75fc (diff) |
Convert to arc4random_uniform.
ok krw@
Diffstat (limited to 'sbin/dhclient')
-rw-r--r-- | sbin/dhclient/dhclient.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 890586b4823..a40daab24cd 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.367 2015/12/05 13:09:11 claudio Exp $ */ +/* $OpenBSD: dhclient.c,v 1.368 2015/12/07 07:40:47 tb Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -1286,14 +1286,13 @@ send_discover(void) if (!client->interval) client->interval = config->initial_interval; else { - client->interval += (arc4random() >> 2) % - (2 * client->interval); + client->interval += arc4random_uniform(2 * client->interval); } /* Don't backoff past cutoff. */ if (client->interval > config->backoff_cutoff) - client->interval = ((config->backoff_cutoff / 2) + - ((arc4random() >> 2) % config->backoff_cutoff)); + client->interval = (config->backoff_cutoff / 2) + + arc4random_uniform(config->backoff_cutoff); /* If the backoff would take us to the panic timeout, just use that as the interval. */ @@ -1410,13 +1409,12 @@ send_request(void) if (!client->interval) client->interval = config->initial_interval; else - client->interval += ((arc4random() >> 2) % - (2 * client->interval)); + client->interval += arc4random_uniform(2 * client->interval); /* Don't backoff past cutoff. */ if (client->interval > config->backoff_cutoff) - client->interval = ((config->backoff_cutoff / 2) + - ((arc4random() >> 2) % client->interval)); + client->interval = (config->backoff_cutoff / 2) + + arc4random_uniform(client->interval); /* * If the backoff would take us to the expiry time, just set the |