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: 597231 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qP6Yd59ktz9snk for ; Tue, 15 Mar 2016 06:01:57 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=IhbGRPsj; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=pC1W0D8NkLVyFWQDh6ZEJcZ6FBp6IorS+vc7I327rasYhjifjovj8 CB0O/KTK5XWKEDup7fy9xUBSyWqD7xUcG1uVX+Z5flBSpIllnvKbd2GNhcmVhAHN TpH4BZaZAbvapoYjtw6gISzRo2S3I+9w9Ew53nXl0dTViMeQ+CxJvg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; s=default; bh=D6C92WmWaeJRQvZ9hwEwD0MLIOE=; b=IhbGRPsjt+zFiGcevH4ZfqWRBPJI uYQft3HULuLiEQIfePvgG+Q9Cz/1qygxfzfpc1WfCy7I44vbYlFMKNZH1fp/K6M6 sOrUxGyWKBcaYaScdYvJUoENM5Zf1VznUG158G8umdISKqjld0a4q39qcf+3hp7N 79y6P4ObTW9g+WU= 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]);