From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 247C33851C39; Wed, 20 May 2020 00:19:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 247C33851C39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.193] (unknown [192.222.164.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 6B2631E5F9; Tue, 19 May 2020 20:19:09 -0400 (EDT) Subject: Re: PR25993, read of freed memory To: Alan Modra Cc: binutils@sourceware.org, gdb-patches@sourceware.org References: <20200519043205.GT1088@bubble.grove.modra.org> <111d8c5d-d615-e0ae-36de-519c43a51139@simark.ca> <20200519234014.GA16809@bubble.grove.modra.org> From: Simon Marchi Message-ID: <6de2c911-78b4-4a8e-6b40-5166211ee07a@simark.ca> Date: Tue, 19 May 2020 20:19:08 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200519234014.GA16809@bubble.grove.modra.org> Content-Type: text/plain; charset=utf-8 Content-Language: tl Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2020 00:19:11 -0000 On 2020-05-19 7:40 p.m., Alan Modra wrote: > On Tue, May 19, 2020 at 09:27:15AM -0400, Simon Marchi wrote: >> On 2020-05-19 12:32 a.m., Alan Modra via Gdb-patches wrote: >>> -void bfd_set_filename (bfd *abfd, char *filename); >>> +char *bfd_set_filename (bfd *abfd, const char *filename); >> Should this return a `const char *`, just like bfd_get_filename? >> >> I haven't inspected all call sites, but it sounds like the caller >> shouldn't be able to modify the filename contents. > Yes, I've updated the return type. One minor change needed to > mach-o.c. > >> Since the string gets copied by bfd_set_filename, let's use std::string >> to avoid having to free: > Done, and symfile-mem.c updated as per down-thread suggestion to make > name a const char*. > > I've left the return status from bfd_set_filename in gdb unchecked, > ie. the out-of-memory NULL return, since it seems to me that not > getting the expected name change is a minor detail very likely to be > lost in some later OOM. That LGTM for the GDB side, but I get a build failure in bfd/archive.c. I think bfd-in2.h needs to be regenerated? Or maybe in BFD you don't typically include re-generated files in your patches? Simon