]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3531. [bug] win32: A uninitialized value could be returned on out
authorMark Andrews <marka@isc.org>
Thu, 21 Mar 2013 22:21:30 +0000 (09:21 +1100)
committerMark Andrews <marka@isc.org>
Thu, 21 Mar 2013 22:23:17 +0000 (09:23 +1100)
                        of memory. [RT #32960]

CHANGES
lib/isc/unix/socket.c
lib/isc/win32/socket.c

diff --git a/CHANGES b/CHANGES
index 0c7ff293e8f4402acd8cdff94d4e99584e3f22d4..95247097dfce1f8d73e873da4a36e23c34050d44 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+3531.  [bug]           win32: A uninitialized value could be returned on out
+                       of memory. [RT #32960]
+
 3530.  [contrib]       Better RTT tracking in queryperf. [RT #30128]
 
 3526.  [cleanup]       Set up dependencies for unit tests correctly during
index 6ef1862eb21fb2f17418da4614f3008703bd4e94..7cdf77cb9921ada53e0a881d0e24d52e96017645 100644 (file)
@@ -2054,7 +2054,7 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type,
        sock->sendcmsgbuf = NULL;
 
        /*
-        * set up cmsg buffers
+        * Set up cmsg buffers.
         */
        cmsgbuflen = 0;
 #if defined(USE_CMSG) && defined(ISC_PLATFORM_HAVEIN6PKTINFO)
@@ -2096,7 +2096,7 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type,
        sock->tag = NULL;
 
        /*
-        * set up list of readers and writers to be initially empty
+        * Set up list of readers and writers to be initially empty.
         */
        ISC_LIST_INIT(sock->recv_list);
        ISC_LIST_INIT(sock->send_list);
@@ -2111,7 +2111,7 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type,
        sock->bound = 0;
 
        /*
-        * initialize the lock
+        * Initialize the lock.
         */
        result = isc_mutex_init(&sock->lock);
        if (result != ISC_R_SUCCESS) {
@@ -2121,7 +2121,7 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type,
        }
 
        /*
-        * Initialize readable and writable events
+        * Initialize readable and writable events.
         */
        ISC_EVENT_INIT(&sock->readable_ev, sizeof(intev_t),
                       ISC_EVENTATTR_NOPURGE, NULL, ISC_SOCKEVENT_INTR,
index 1648e56b672fd88d24e0c6b9d3ee16380a96c8fc..fe71fbed4105db29b5b3954a2e9a9b7cd136b074 100644 (file)
@@ -1461,7 +1461,7 @@ allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type,
        ISC_LINK_INIT(sock, link);
 
        /*
-        * set up list of readers and writers to be initially empty
+        * Set up list of readers and writers to be initially empty.
         */
        ISC_LIST_INIT(sock->recv_list);
        ISC_LIST_INIT(sock->send_list);
@@ -1483,20 +1483,16 @@ allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type,
        sock->recvbuf.remaining = 0;
        sock->recvbuf.base = isc_mem_get(manager->mctx, sock->recvbuf.len); // max buffer size
        if (sock->recvbuf.base == NULL) {
-               sock->magic = 0;
+               result = ISC_R_NOMEMORY;
                goto error;
        }
 
        /*
-        * initialize the lock
+        * Initialize the lock.
         */
        result = isc_mutex_init(&sock->lock);
-       if (result != ISC_R_SUCCESS) {
-               sock->magic = 0;
-               isc_mem_put(manager->mctx, sock->recvbuf.base, sock->recvbuf.len);
-               sock->recvbuf.base = NULL;
+       if (result != ISC_R_SUCCESS)
                goto error;
-       }
 
        socket_log(__LINE__, sock, NULL, EVENT, NULL, 0, 0,
                   "allocated");
@@ -1507,6 +1503,8 @@ allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type,
        return (ISC_R_SUCCESS);
 
  error:
+       if (sock->recvbuf.base != NULL)
+               isc_mem_put(manager->mctx, sock->recvbuf.base, sock->recvbuf.len);
        isc_mem_put(manager->mctx, sock, sizeof(*sock));
 
        return (result);