]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
pullup:
authorBrian Wellington <source@isc.org>
Wed, 7 Feb 2001 20:21:46 +0000 (20:21 +0000)
committerBrian Wellington <source@isc.org>
Wed, 7 Feb 2001 20:21:46 +0000 (20:21 +0000)
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]

CHANGES
lib/isc/unix/socket.c

diff --git a/CHANGES b/CHANGES
index 9fcbcc32766ff6e08e38781aa22efe899af04b90..ff7f54443d26970fb8ffd65a0b76aee17abe262f 100644 (file)
--- 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]
 
index 99bf26b85f7464cc1fa7f0b037c31c5863ab95f0..6c4faac43d2cd11f5ce5895a4939c5b8fd9ad5de 100644 (file)
@@ -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 <config.h>
 
@@ -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.
         */