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,
_______________________________________________
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"

Reply via email to