Date: Sun, 16 Aug 2015 23:23:59 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r286834 - head/sbin/ping6 Message-ID: <201508162323.t7GNNxpt032240@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: delphij Date: Sun Aug 16 23:23:58 2015 New Revision: 286834 URL: https://svnweb.freebsd.org/changeset/base/286834 Log: Use arc4random_buf(). While there, unifdef the code for HAVE_ARC4RANDOM. MFC after: 2 weeks Modified: head/sbin/ping6/Makefile head/sbin/ping6/ping6.c Modified: head/sbin/ping6/Makefile ============================================================================== --- head/sbin/ping6/Makefile Sun Aug 16 20:13:58 2015 (r286833) +++ head/sbin/ping6/Makefile Sun Aug 16 23:23:58 2015 (r286834) @@ -3,8 +3,7 @@ PROG= ping6 MAN= ping6.8 -CFLAGS+=-DIPSEC -DKAME_SCOPEID -DUSE_RFC2292BIS \ - -DHAVE_ARC4RANDOM +CFLAGS+=-DIPSEC -DKAME_SCOPEID -DUSE_RFC2292BIS WARNS?= 3 BINOWN= root Modified: head/sbin/ping6/ping6.c ============================================================================== --- head/sbin/ping6/ping6.c Sun Aug 16 20:13:58 2015 (r286833) +++ head/sbin/ping6/ping6.c Sun Aug 16 23:23:58 2015 (r286834) @@ -288,9 +288,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; @@ -751,17 +748,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 < (int)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?201508162323.t7GNNxpt032240>