]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3267. [bug] Memory allocation failures could be mis-reported as
authorMark Andrews <marka@isc.org>
Fri, 27 Jan 2012 01:21:41 +0000 (01:21 +0000)
committerMark Andrews <marka@isc.org>
Fri, 27 Jan 2012 01:21:41 +0000 (01:21 +0000)
                        unexpected error.  New ISC_R_UNSET result code.                        [RT #27336]

CHANGES
lib/isc/include/isc/result.h
lib/isc/result.c
lib/isc/unix/socket.c

diff --git a/CHANGES b/CHANGES
index b747aa8e1a9b08edb94f561fab6acf23cf4f4756..95959d8ceb20798431c676cafa1ad366145d12b7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+3267.  [bug]           Memory allocation failures could be mis-reported as
+                       unexpected error.  New ISC_R_UNSET result code.
+                       [RT #27336]
+
 3266.  [bug]           The maximum number of NSEC3 iterations for a
                        DNSKEY RRset was not being properly computed.
                        [RT #26543]
index 2347d5f80c9728f177352e14d7e73bf314891c75..8b0c797c1b7a3fb1fe3c0a5ad177d62932a37095 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: result.h,v 1.73 2009/09/02 23:48:03 tbox Exp $ */
+/* $Id: result.h,v 1.74 2012/01/27 01:21:41 marka Exp $ */
 
 #ifndef ISC_RESULT_H
 #define ISC_RESULT_H 1
 #define ISC_R_MAXSIZE                  58      /*%< max size */
 #define ISC_R_BADADDRESSFORM           59      /*%< invalid address format */
 #define ISC_R_BADBASE32                        60      /*%< bad base32 encoding */
+#define ISC_R_UNSET                    61      /*%< unset */
 
 /*% Not a result code: the number of results. */
-#define ISC_R_NRESULTS                         61
+#define ISC_R_NRESULTS                         62
 
 ISC_LANG_BEGINDECLS
 
index 571358054e8f9b60a75cafbcdde42f57f66f35e6..28269bafaf3b627314b5972ba76ba8d053c3bdbf 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: result.c,v 1.71 2008/09/25 04:02:39 tbox Exp $ */
+/* $Id: result.c,v 1.72 2012/01/27 01:21:41 marka Exp $ */
 
 /*! \file */
 
@@ -102,6 +102,7 @@ static const char *text[ISC_R_NRESULTS] = {
        "max size",                             /*%< 58 */
        "invalid address format",               /*%< 59 */
        "bad base32 encoding",                  /*%< 60 */
+       "unset",                                /*%< 61 */
 };
 
 #define ISC_RESULT_RESULTSET                   2
index f20f3d31ffa2f4ee7812fdc1d33edb531f0f1ba3..42d2b73e79b1ecbba9477e8ebc11f0935f85bb33 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: socket.c,v 1.349 2011/11/29 01:03:47 marka Exp $ */
+/* $Id: socket.c,v 1.350 2012/01/27 01:21:41 marka Exp $ */
 
 /*! \file */
 
@@ -1595,7 +1595,7 @@ allocate_socketevent(isc__socket_t *sock, isc_eventtype_t eventtype,
        if (ev == NULL)
                return (NULL);
 
-       ev->result = ISC_R_UNEXPECTED;
+       ev->result = ISC_R_UNSET;
        ISC_LINK_INIT(ev, ev_link);
        ISC_LIST_INIT(ev->bufferlist);
        ev->region.base = NULL;
@@ -2048,8 +2048,6 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type,
        if (sock == NULL)
                return (ISC_R_NOMEMORY);
 
-       result = ISC_R_UNEXPECTED;
-
        sock->common.magic = 0;
        sock->common.impmagic = 0;
        sock->references = 0;
@@ -2078,8 +2076,10 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type,
        sock->recvcmsgbuflen = cmsgbuflen;
        if (sock->recvcmsgbuflen != 0U) {
                sock->recvcmsgbuf = isc_mem_get(manager->mctx, cmsgbuflen);
-               if (sock->recvcmsgbuf == NULL)
+               if (sock->recvcmsgbuf == NULL) {
+                       result = ISC_R_NOMEMORY;
                        goto error;
+               }
        }
 
        cmsgbuflen = 0;
@@ -2096,8 +2096,10 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type,
        sock->sendcmsgbuflen = cmsgbuflen;
        if (sock->sendcmsgbuflen != 0U) {
                sock->sendcmsgbuf = isc_mem_get(manager->mctx, cmsgbuflen);
-               if (sock->sendcmsgbuf == NULL)
+               if (sock->sendcmsgbuf == NULL) {
+                       result = ISC_R_NOMEMORY;
                        goto error;
+               }
        }
 
        memset(sock->name, 0, sizeof(sock->name));
@@ -2235,7 +2237,9 @@ clear_bsdcompat(void) {
 
 static isc_result_t
 opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
-          isc__socket_t *dup_socket) {
+          isc__socket_t *dup_socket)
+{
+       isc_result_t result;
        char strbuf[ISC_STRERRORSIZE];
        const char *err = "socket";
        int tries = 0;
@@ -2350,9 +2354,10 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
        if (dup_socket != NULL)
                goto setup_done;
 
-       if (make_nonblock(sock->fd) != ISC_R_SUCCESS) {
+       result = make_nonblock(sock->fd);
+       if (result != ISC_R_SUCCESS) {
                (void)close(sock->fd);
-               return (ISC_R_UNEXPECTED);
+               return (result);
        }
 
 #ifdef SO_BSDCOMPAT
@@ -3247,10 +3252,12 @@ internal_accept(isc_task_t *me, isc_event_t *ev) {
 
        UNLOCK(&sock->lock);
 
-       if (fd != -1 && (make_nonblock(fd) != ISC_R_SUCCESS)) {
-               (void)close(fd);
-               fd = -1;
-               result = ISC_R_UNEXPECTED;
+       if (fd != -1) {
+               result = make_nonblock(fd);
+               if (result != ISC_R_SUCCESS) {
+                       (void)close(fd);
+                       fd = -1;
+               }
        }
 
        /*
@@ -4609,7 +4616,7 @@ isc__socket_recv2(isc_socket_t *sock0, isc_region_t *region,
        isc__socket_t *sock = (isc__socket_t *)sock0;
 
        event->ev_sender = sock;
-       event->result = ISC_R_UNEXPECTED;
+       event->result = ISC_R_UNSET;
        ISC_LIST_INIT(event->bufferlist);
        event->region = *region;
        event->n = 0;
@@ -4823,7 +4830,7 @@ isc__socket_sendto2(isc_socket_t *sock0, isc_region_t *region,
        if ((flags & ISC_SOCKFLAG_NORETRY) != 0)
                REQUIRE(sock->type == isc_sockettype_udp);
        event->ev_sender = sock;
-       event->result = ISC_R_UNEXPECTED;
+       event->result = ISC_R_UNSET;
        ISC_LIST_INIT(event->bufferlist);
        event->region = *region;
        event->n = 0;