diff options
| author | 2019-12-16 16:16:22 +0000 | |
|---|---|---|
| committer | 2019-12-16 16:16:22 +0000 | |
| commit | 2fc5abb04c862f358e234358caea4444e15db068 (patch) | |
| tree | 1c77d5b577fef0399be14245b2108ca9c1a8819d /usr.sbin/bind/lib/isc/unix/entropy.c | |
| parent | Need to include message size in the maximum buffer calculation. (diff) | |
| download | wireguard-openbsd-2fc5abb04c862f358e234358caea4444e15db068.tar.xz wireguard-openbsd-2fc5abb04c862f358e234358caea4444e15db068.zip | |
Update to bind-9.10.5-P3, which appears to have been the last ISC version.
We only use this tree to build dig and nslookup. Our previous version
predated edns0 support in those tools, and we want that. This is the worst
code I've looked at in years, with layers and layers of spaghetti abstraction
clearly unfit for reuse, but then reused anyways, and the old ones remain
behind. So this is a 8MB diff.
florian, sthen, and otto tried this merge before but failed.
Diffstat (limited to 'usr.sbin/bind/lib/isc/unix/entropy.c')
| -rw-r--r-- | usr.sbin/bind/lib/isc/unix/entropy.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/usr.sbin/bind/lib/isc/unix/entropy.c b/usr.sbin/bind/lib/isc/unix/entropy.c index ebe812129fb..c13d3fd2ce5 100644 --- a/usr.sbin/bind/lib/isc/unix/entropy.c +++ b/usr.sbin/bind/lib/isc/unix/entropy.c @@ -1,8 +1,8 @@ /* - * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2008, 2012 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2003 Internet Software Consortium. * - * Permission to use, copy, modify, and distribute this software for any + * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $ISC: entropy.c,v 1.71.18.7 2006/12/07 04:53:03 marka Exp $ */ +/* $Id: entropy.c,v 1.7 2019/12/16 16:16:27 deraadt Exp $ */ /* \file unix/entropy.c * \brief @@ -31,6 +31,9 @@ #include <sys/socket.h> #include <sys/un.h> +#ifdef HAVE_NANOSLEEP +#include <time.h> +#endif #include <unistd.h> #include <isc/platform.h> @@ -153,12 +156,12 @@ get_from_usocketsource(isc_entropysource_t *source, isc_uint32_t desired) { source->sources.usocket.status = isc_usocketsource_ndesired; goto eagain_loop; - } + } INSIST(n == 2); source->sources.usocket.status = isc_usocketsource_wrote; /*FALLTHROUGH*/ - + case isc_usocketsource_wrote: if (recvfrom(fd, buf, 1, 0, NULL, NULL) != 1) { if (errno == EAGAIN) { @@ -166,15 +169,23 @@ get_from_usocketsource(isc_entropysource_t *source, isc_uint32_t desired) { * The problem of EAGAIN (try again * later) is a major issue on HP-UX. * Solaris actually tries the recvfrom - * call again, while HP-UX just dies. + * call again, while HP-UX just dies. * This code is an attempt to let the * entropy pool fill back up (at least * that's what I think the problem is.) - * We go to eagain_loop because if we + * We go to eagain_loop because if we * just "break", then the "desired" * amount gets borked. */ +#ifdef HAVE_NANOSLEEP + struct timespec ts; + + ts.tv_sec = 0; + ts.tv_nsec = 1000000; + nanosleep(&ts, NULL); +#else usleep(1000); +#endif goto eagain_loop; } if (errno == EWOULDBLOCK || errno == EINTR) @@ -201,7 +212,7 @@ get_from_usocketsource(isc_entropysource_t *source, isc_uint32_t desired) { } else n = 0; break; - + default: goto err; } @@ -452,7 +463,7 @@ make_nonblock(int fd) { ret = ioctl(fd, FIONBIO, (char *)&on); #else - flags = fcntl(fd, F_GETFL); + flags = fcntl(fd, F_GETFL, 0); flags |= PORT_NONBLOCK; ret = fcntl(fd, F_SETFL, flags); #endif @@ -491,7 +502,7 @@ isc_entropy_createfilesource(isc_entropy_t *ent, const char *fname) { ret = isc__errno2result(errno); goto errout; } - /* + /* * Solaris 2.5.1 does not have support for sockets (S_IFSOCK), * but it does return type S_IFIFO (the OS believes that * the socket is a fifo). This may be an issue if we tell |
