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: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-4.2 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 [8.43.85.97]) (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 4E2631F8C6 for ; Tue, 3 Aug 2021 15:46:45 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 468EF395ACD2 for ; Tue, 3 Aug 2021 15:46:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 468EF395ACD2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1628005604; bh=1xBb5CgdUaGiT/2jUZUDS6y5ELDi4thValT8DTcc2Js=; 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=ZKtj04lF+83KT4p58eL29JP1hU1nNOyWbANye+BumbE9daRi/PllRi+ISeL8Rukzl q/V9jaklgHOEcILmO2jXpF62BDZXm36TrsmUdSYvx3aC2OBXEihGo3SBJ0PwJa3XWw 3WA3wP0peamXENIxiTmNX0LXHXA9P5mFDPdZ39mk= Received: from anamika.lostca.se (anamika.lostca.se [IPv6:2a01:4f9:3b:505c::2]) by sourceware.org (Postfix) with ESMTPS id 00E4D3959E55; Tue, 3 Aug 2021 15:34:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 00E4D3959E55 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 AB8941B2E4; Tue, 3 Aug 2021 15:34:44 +0000 (UTC) Date: Tue, 3 Aug 2021 15:34:44 +0000 To: Siddhesh Poyarekar Subject: Re: [PATCH 5/5] gaiconf_init: Avoid double-free in label and precedence lists Message-ID: <20210803153444.GE6986@lostca.se> References: <20210727174129.3612656-1-siddhesh@sourceware.org> <20210727174129.3612656-6-siddhesh@sourceware.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210727174129.3612656-6-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, > labellist and precedencelist could get freed a second time if there > are allocation failures, so set them to NULL to avoid a double-free. > --- > sysdeps/posix/getaddrinfo.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c > index 838a68f022..43dfc6739e 100644 > --- a/sysdeps/posix/getaddrinfo.c > +++ b/sysdeps/posix/getaddrinfo.c > @@ -2008,6 +2008,7 @@ gaiconf_init (void) > l = l->next; > } > free_prefixlist (labellist); > + labellist = NULL; > > /* Sort the entries so that the most specific ones are at > the beginning. */ > @@ -2046,6 +2047,7 @@ gaiconf_init (void) > l = l->next; > } > free_prefixlist (precedencelist); > + precedencelist = NULL; > > /* Sort the entries so that the most specific ones are at > the beginning. */ Looks good to me. Yes, a later allocation failure can trigger a `goto no_file' which tries to free these (again, in this case). Setting to NULL avoids that. Reviewed-by: Arjun Shankar Cheers!