summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2015-08-31 18:53:41 +0000
committerdelphij <delphij@FreeBSD.org>2015-08-31 18:53:41 +0000
commitedf242860fdfdb24b57aa62019de5e30a4cb053f (patch)
tree1e6af4dcd8d8af4847b34a0c18ec5350f60d72bf /sbin
parent509a57d66e3a1e7c373a215bb19dbe67cbb6b13e (diff)
downloadFreeBSD-src-edf242860fdfdb24b57aa62019de5e30a4cb053f.zip
FreeBSD-src-edf242860fdfdb24b57aa62019de5e30a4cb053f.tar.gz
MFC r286834:
Use arc4random_buf(). While there, unifdef the code for !HAVE_ARC4RANDOM.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ping6/Makefile3
-rw-r--r--sbin/ping6/ping6.c15
2 files changed, 2 insertions, 16 deletions
diff --git a/sbin/ping6/Makefile b/sbin/ping6/Makefile
index 7f3a008..a777c62 100644
--- a/sbin/ping6/Makefile
+++ b/sbin/ping6/Makefile
@@ -3,8 +3,7 @@
PROG= ping6
MAN= ping6.8
-CFLAGS+=-DIPSEC -DKAME_SCOPEID -DUSE_RFC2292BIS \
- -DHAVE_ARC4RANDOM
+CFLAGS+=-DIPSEC -DKAME_SCOPEID -DUSE_RFC2292BIS
WARNS?= 2
BINOWN= root
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c
index 9ad285c..3806daa 100644
--- a/sbin/ping6/ping6.c
+++ b/sbin/ping6/ping6.c
@@ -289,9 +289,6 @@ main(int argc, char *argv[])
{
struct timeval last, intvl;
struct sockaddr_in6 from, *sin6;
-#ifndef HAVE_ARC4RANDOM
- struct timeval seed;
-#endif
struct addrinfo hints, *res;
struct sigaction si_sa;
int cc, i;
@@ -743,17 +740,7 @@ main(int argc, char *argv[])
*datap++ = i;
ident = getpid() & 0xFFFF;
-#ifndef HAVE_ARC4RANDOM
- gettimeofday(&seed, NULL);
- srand((unsigned int)(seed.tv_sec ^ seed.tv_usec ^ (long)ident));
- memset(nonce, 0, sizeof(nonce));
- for (i = 0; i < sizeof(nonce); i += sizeof(int))
- *((int *)&nonce[i]) = rand();
-#else
- memset(nonce, 0, sizeof(nonce));
- for (i = 0; i < sizeof(nonce); i += sizeof(u_int32_t))
- *((u_int32_t *)&nonce[i]) = arc4random();
-#endif
+ arc4random_buf(nonce, sizeof(nonce));
optval = 1;
if (options & F_DONTFRAG)
if (setsockopt(s, IPPROTO_IPV6, IPV6_DONTFRAG,
OpenPOWER on IntegriCloud