From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bumble.maple.relay.mailchannels.net (bumble.maple.relay.mailchannels.net [23.83.214.25]) by sourceware.org (Postfix) with ESMTPS id EBAE5393C842 for ; Wed, 4 Aug 2021 10:27:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EBAE5393C842 X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id AFD282E05D4; Wed, 4 Aug 2021 10:27:37 +0000 (UTC) Received: from pdx1-sub0-mail-a4.g.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id D26F02E05A0; Wed, 4 Aug 2021 10:27:36 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a4.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.123.194.46 (trex/6.3.3); Wed, 04 Aug 2021 10:27:37 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Celery-Sponge: 2d96545560e6e012_1628072857259_1435294150 X-MC-Loop-Signature: 1628072857259:1896636987 X-MC-Ingress-Time: 1628072857259 Received: from pdx1-sub0-mail-a4.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a4.g.dreamhost.com (Postfix) with ESMTP id 8A32F8AAB3; Wed, 4 Aug 2021 03:27:36 -0700 (PDT) Received: from rhbox.redhat.com (unknown [1.186.101.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a4.g.dreamhost.com (Postfix) with ESMTPSA id 656918AAAB; Wed, 4 Aug 2021 03:27:33 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a4 From: Siddhesh Poyarekar To: libc-stable@sourceware.org Cc: Arjun Shankar Subject: [committed 2.34 2/5] gconv_parseconfdir: Fix memory leak Date: Wed, 4 Aug 2021 15:57:19 +0530 Message-Id: <20210804102722.3103199-2-siddhesh@sourceware.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210804102722.3103199-1-siddhesh@sourceware.org> References: <20210804102722.3103199-1-siddhesh@sourceware.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3494.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-stable@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-stable mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Aug 2021 10:27:40 -0000 The allocated `conf` would leak if we have to skip over the file due to the underlying filesystem not supporting dt_type. Reviewed-by: Arjun Shankar (cherry picked from commit 5f9b78fe35d08739b6da1e5b356786d41116c108) --- iconv/gconv_parseconfdir.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/iconv/gconv_parseconfdir.h b/iconv/gconv_parseconfdir.h index a4153e54c6..2f062689ec 100644 --- a/iconv/gconv_parseconfdir.h +++ b/iconv/gconv_parseconfdir.h @@ -153,12 +153,11 @@ gconv_parseconfdir (const char *dir, size_t dir_len= ) struct stat64 st; if (asprintf (&conf, "%s/%s", buf, ent->d_name) < 0) continue; - if (ent->d_type =3D=3D DT_UNKNOWN - && (lstat64 (conf, &st) =3D=3D -1 - || !S_ISREG (st.st_mode))) - continue; =20 - found |=3D read_conf_file (conf, dir, dir_len); + if (ent->d_type !=3D DT_UNKNOWN + || (lstat64 (conf, &st) !=3D -1 && S_ISREG (st.st_mode))) + found |=3D read_conf_file (conf, dir, dir_len); + free (conf); } } --=20 2.31.1