Use arc4random_buf(). While there, unifdef the code for HAVE_ARC4RANDOM.
MFC after: 2 weeks
This commit is contained in:
parent
7c669ab6cc
commit
1ae1bd497f
@ -3,8 +3,7 @@
|
|||||||
PROG= ping6
|
PROG= ping6
|
||||||
MAN= ping6.8
|
MAN= ping6.8
|
||||||
|
|
||||||
CFLAGS+=-DIPSEC -DKAME_SCOPEID -DUSE_RFC2292BIS \
|
CFLAGS+=-DIPSEC -DKAME_SCOPEID -DUSE_RFC2292BIS
|
||||||
-DHAVE_ARC4RANDOM
|
|
||||||
WARNS?= 3
|
WARNS?= 3
|
||||||
|
|
||||||
BINOWN= root
|
BINOWN= root
|
||||||
|
@ -288,9 +288,6 @@ main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
struct timeval last, intvl;
|
struct timeval last, intvl;
|
||||||
struct sockaddr_in6 from, *sin6;
|
struct sockaddr_in6 from, *sin6;
|
||||||
#ifndef HAVE_ARC4RANDOM
|
|
||||||
struct timeval seed;
|
|
||||||
#endif
|
|
||||||
struct addrinfo hints, *res;
|
struct addrinfo hints, *res;
|
||||||
struct sigaction si_sa;
|
struct sigaction si_sa;
|
||||||
int cc, i;
|
int cc, i;
|
||||||
@ -751,17 +748,7 @@ main(int argc, char *argv[])
|
|||||||
*datap++ = i;
|
*datap++ = i;
|
||||||
|
|
||||||
ident = getpid() & 0xFFFF;
|
ident = getpid() & 0xFFFF;
|
||||||
#ifndef HAVE_ARC4RANDOM
|
arc4random_buf(nonce, sizeof(nonce));
|
||||||
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
|
|
||||||
optval = 1;
|
optval = 1;
|
||||||
if (options & F_DONTFRAG)
|
if (options & F_DONTFRAG)
|
||||||
if (setsockopt(s, IPPROTO_IPV6, IPV6_DONTFRAG,
|
if (setsockopt(s, IPPROTO_IPV6, IPV6_DONTFRAG,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user