From 96c973a6a96f10c93ede4c66964ceae47535a07a Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Mon, 26 Jan 2004 23:33:32 +0000 Subject: [PATCH] 1562. [bug] isc_socket_create() and isc_socket_accept() could leak memory under error conditions. [RT #10230] --- CHANGES | 3 +++ lib/isc/unix/socket.c | 5 +++-- lib/isc/win32/socket.c | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index c1ba433ee5..1a3f88ba70 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +1562. [bug] isc_socket_create() and isc_socket_accept() could + leak memory under error conditions. [RT #10230] + 1561. [bug] It was possible to release the same name twice if named ran out of memory. [RT #10197] diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 560b591b08..c8fa919170 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.232 2003/07/25 00:01:13 marka Exp $ */ +/* $Id: socket.c,v 1.233 2004/01/26 23:33:32 marka Exp $ */ #include @@ -1246,7 +1246,8 @@ allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type, return (ISC_R_SUCCESS); - error: /* socket allocated */ + error: + isc_mem_put(manager->mctx, sock, sizeof(*sock)); return (ret); } diff --git a/lib/isc/win32/socket.c b/lib/isc/win32/socket.c index b03c93d295..b1196d7e78 100644 --- a/lib/isc/win32/socket.c +++ b/lib/isc/win32/socket.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket.c,v 1.27 2004/01/08 08:23:11 marka Exp $ */ +/* $Id: socket.c,v 1.28 2004/01/26 23:33:32 marka Exp $ */ /* This code has been rewritten to take advantage of Windows Sockets * I/O Completion Ports and Events. I/O Completion Ports is ONLY @@ -1754,10 +1754,12 @@ allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type, return (ISC_R_SUCCESS); - error: /* socket allocated */ + error: + isc_mem_put(manager->mctx, sock, sizeof(*sock)); return (ret); } + /* * This event requires that the various lists be empty, that the reference * count be 1, and that the magic number is valid. The other socket bits,