From patchwork Mon Mar 14 19:01:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 11335 Received: (qmail 20426 invoked by alias); 14 Mar 2016 19:01:47 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 19814 invoked by uid 89); 14 Mar 2016 19:01:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.0 required=5.0 tests=BAYES_20, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=2.7.0, samuel, Samuel, H*r:4.86_2 X-HELO: hall.aurel32.net From: Aurelien Jarno To: libc-alpha@sourceware.org Cc: Aurelien Jarno Subject: [PATCH] Fix memory leak in __res_vinit/__res_iclose Date: Mon, 14 Mar 2016 20:01:29 +0100 Message-Id: <1457982089-16937-1-git-send-email-aurelien@aurel32.net> When resolv.conf contains IPv6 nameservers, __res_vinit stores their address in malloced areas, pointed by statp->_u._ext.nsaddrs. They are supposed to be freed later by __res_iclose, but it doesn't work as the loop is done on statp->_u._ext.nscount instead of statp->nscount. This causes a memory leak. This patch fixes it. Changelog: [BZ #19527] * resolv/res_init.c (__res_iclose): Loop on statp->nscount instead of statp->_u._ext.nscount. --- ChangeLog | 6 ++++++ resolv/res_init.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 4cc920d..2b390ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-03-14 Aurelien Jarno + + [BZ #19527] + * resolv/res_init.c (__res_iclose): Loop on statp->nscount instead of + statp->_u._ext.nscount. + 2016-03-13 Samuel Thibault _vcsock = -1; statp->_flags &= ~(RES_F_VC | RES_F_CONN); } - for (ns = 0; ns < statp->_u._ext.nscount; ns++) + for (ns = 0; ns < statp->nscount; ns++) if (statp->_u._ext.nsaddrs[ns]) { if (statp->_u._ext.nssocks[ns] != -1) { close_not_cancel_no_status(statp->_u._ext.nssocks[ns]);