From: Brian Wellington Date: Wed, 7 Feb 2001 20:21:46 +0000 (+0000) Subject: pullup: X-Git-Tag: v9.1.1rc1~2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=470a973e506f984fbef1ab87c0865c592400e4e3;p=thirdparty%2Fbind9.git pullup: 727. [port] Work around OS bug where accept() succeeds but fails to fill in the peer address of the accepted connection, by treating it as an error rather than an assertion failure. [RT #809] --- diff --git a/CHANGES b/CHANGES index 9fcbcc32766..ff7f54443d2 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,11 @@ --- 9.1.1rc1 released --- + 727. [port] Work around OS bug where accept() succeeds but + fails to fill in the peer address of the accepted + connection, by treating it as an error rather than + an assertion failure. [RT #809] + 723. [bug] Referrals whose NS RRs had a 0 TTL caused the resolver to return DNS_R_SERVFAIL. [RT #783] diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 99bf26b85f7..6c4faac43d2 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket.c,v 1.178.2.3 2001/02/06 18:10:28 gson Exp $ */ +/* $Id: socket.c,v 1.178.2.4 2001/02/07 20:21:46 bwelling Exp $ */ #include @@ -1652,41 +1652,41 @@ internal_accept(isc_task_t *me, isc_event_t *ev) { * again. */ addrlen = sizeof dev->newsocket->address.type; + memset(&dev->newsocket->address.type.sa, 0, addrlen); fd = accept(sock->fd, &dev->newsocket->address.type.sa, (void *)&addrlen); if (fd < 0) { - if (SOFT_ERROR(errno)) { + if (! SOFT_ERROR(errno)) { + UNEXPECTED_ERROR(__FILE__, __LINE__, + "internal_accept: accept() %s: %s", + isc_msgcat_get(isc_msgcat, + ISC_MSGSET_GENERAL, + ISC_MSG_FAILED, + "failed"), + strerror(errno)); + } + select_poke(sock->manager, sock->fd); + UNLOCK(&sock->lock); + return; + } else { + if (dev->newsocket->address.type.sa.sa_family != sock->pf) { + UNEXPECTED_ERROR(__FILE__, __LINE__, + "internal_accept(): " + "accept() returned peer address " + "family %u (expected %u)", + dev->newsocket->address. + type.sa.sa_family, + sock->pf); + (void)close(fd); select_poke(sock->manager, sock->fd); UNLOCK(&sock->lock); return; } - - /* - * If some other error, ignore it as well and hope - * for the best, but log it. - */ - if (isc_log_wouldlog(isc_lctx, TRACE_LEVEL)) - socket_log(sock, NULL, TRACE, isc_msgcat, - ISC_MSGSET_SOCKET, - ISC_MSG_ACCEPTRETURNED, - "accept() returned %d/%s", - errno, strerror(errno)); - - fd = -1; - - UNEXPECTED_ERROR(__FILE__, __LINE__, - "internal_accept: accept() %s: %s", - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed"), - strerror(errno)); - - result = ISC_R_UNEXPECTED; - } else { - INSIST(dev->newsocket->address.type.sa.sa_family == sock->pf); - dev->newsocket->address.length = addrlen; - dev->newsocket->pf = sock->pf; } + dev->newsocket->address.length = addrlen; + dev->newsocket->pf = sock->pf; + /* * Pull off the done event. */