Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Aug 2015 18:53:42 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r287328 - stable/10/sbin/ping6
Message-ID:  <201508311853.t7VIrgg6040419@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Mon Aug 31 18:53:41 2015
New Revision: 287328
URL: https://svnweb.freebsd.org/changeset/base/287328

Log:
  MFC r286834:
  
  Use arc4random_buf().  While there, unifdef the code for !HAVE_ARC4RANDOM.

Modified:
  stable/10/sbin/ping6/Makefile
  stable/10/sbin/ping6/ping6.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sbin/ping6/Makefile
==============================================================================
--- stable/10/sbin/ping6/Makefile	Mon Aug 31 18:07:17 2015	(r287327)
+++ stable/10/sbin/ping6/Makefile	Mon Aug 31 18:53:41 2015	(r287328)
@@ -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

Modified: stable/10/sbin/ping6/ping6.c
==============================================================================
--- stable/10/sbin/ping6/ping6.c	Mon Aug 31 18:07:17 2015	(r287327)
+++ stable/10/sbin/ping6/ping6.c	Mon Aug 31 18:53:41 2015	(r287328)
@@ -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,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201508311853.t7VIrgg6040419>