From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 9309E1F8C6 for ; Tue, 3 Aug 2021 15:08:37 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 075713955416 for ; Tue, 3 Aug 2021 15:08:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 075713955416 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1628003316; bh=je1lEVStGjnEl8ik2zqP7uyg6NqZd9O7nTBBsx342Q4=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=OvW8VBgr2RYLfJWds8OjWN6TQLnzCDgz5XLA98oUJ8QSGxj0yi3HD00pVyfd3bHIY yda5NWnahyEZMwIuth7XVzpYkjsfqea3DEj/u3FFEHbp9K0nmKBKNh1cXJppZiKRlF hDYtV1SF8liLti8PZk4fny2VbfuBl6q0VBGZU0kY= Received: from anamika.lostca.se (anamika.lostca.se [IPv6:2a01:4f9:3b:505c::2]) by sourceware.org (Postfix) with ESMTPS id A2AC13864838; Tue, 3 Aug 2021 15:08:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A2AC13864838 Received: from localhost (mail.lostca.se [65.21.75.227]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: spectre) by anamika.lostca.se (Postfix) with ESMTPSA id F3B0E1B464; Tue, 3 Aug 2021 15:08:14 +0000 (UTC) Date: Tue, 3 Aug 2021 15:08:14 +0000 To: Siddhesh Poyarekar Subject: Re: [PATCH 1/5] ldconfig: avoid leak on empty paths in config file Message-ID: <20210803150814.GA6986@lostca.se> References: <20210727174129.3612656-1-siddhesh@sourceware.org> <20210727174129.3612656-2-siddhesh@sourceware.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210727174129.3612656-2-siddhesh@sourceware.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Arjun Shankar via Libc-alpha Reply-To: Arjun Shankar Cc: libc-alpha@sourceware.org Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" Hi Siddhesh, > --- > elf/ldconfig.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/elf/ldconfig.c b/elf/ldconfig.c > index 1037e8d0cf..b8893637f8 100644 > --- a/elf/ldconfig.c > +++ b/elf/ldconfig.c > @@ -503,7 +503,11 @@ add_dir_1 (const char *line, const char *from_file, int from_line) > entry->path[--i] = '\0'; > > if (i == 0) > - return; > + { > + free (entry->path); > + free (entry); > + return; > + } > > char *path = entry->path; > if (opt_chroot != NULL) This looks good to me. entry and entry->path are allocated earlier via xmalloc and xstrdup respectively and this frees them prior to an early conditional return. Reviewed-by: Arjun Shankar Cheers!