From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2610:1c1:1:606c::19:2]) by sourceware.org (Postfix) with ESMTPS id 82A3D3858C33 for ; Mon, 14 Aug 2023 17:48:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 82A3D3858C33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 4RPhh60PzZz3Npx; Mon, 14 Aug 2023 17:48:06 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RPhh56BX5z3gvl; Mon, 14 Aug 2023 17:48:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692035285; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RQwn2tlchbP+loTbtYb4mu78l3ikrv1CqRmSTRZ/CoY=; b=ffSnUJGv57pl09yGnSC09BewTh1lKUXK3GJGhfiquiH4C6MEz7e6vl/L7OPr5PF5n+Bl2k wGFCa+jAdwFYiL4w5i4S95UfBWjDaEg0k0tXKrb9CZ/4we+E9NbVa12X3c0npBNBElDPOZ ET3CbQYq4s/x5KS41JLH9xygvbCIvTwUC/EV0zIjyHAYjpnjAF68qe8WjJnGhChoFn83kd 1fee3Un/XfrrNre+qymsYpYrNS9lOk4Hkoyah1442OBaPqafya8WbbdlqEThFb7MQapRJq IMwrLJqP0aQ0+0zPI1PY6o4uVXQ7R7BmjyPcAGMiiqWpt7UtjTn95WUH5oIuyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692035285; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RQwn2tlchbP+loTbtYb4mu78l3ikrv1CqRmSTRZ/CoY=; b=k6Kd7wGWLD+MwC7GMSEUOxCRXoCEz+cCIvtWaePVBWWT7kD1htz/Mjx4Tz5wIvQHiAX9Is +knFwqepzNrcaA+fc1pmcwyjACX0ORr9vwMBKzE8mNJsDCq9MkobokdCCD7UB+CZdsVlo4 YyswAk+0Usg++TyT2Eklsm63vT/3IaLJx/GGuWlkrairRGcl3j2k8+Yqy3POlxn5NR3EAH /+jXmiX2FaenvkdJ8bBrVgS2cSU4orL2u+ULgn2BkjlpUBeDQ9lLlEX8WR1mm0CVRgRKO4 FDmqZ2NeRWqD9vY584alTrukFXvOknhfthThMJqllnXAtG7p9qc32TyCxSf8ng== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1692035285; a=rsa-sha256; cv=none; b=QHWT1AGfF0jEF2V4x/YJ3/B7orjwqWNw1k2V7i64QmfY5Fmmd/luXJVhtS9+uss1s7PanD Euw9PIeEJYY6pwhWy+f8O9oMW0eGPFeeDwj/iMQpCIRJw+k/xFTXOAzZ5dZ9YtmLe/unts W1ImF8xs90tG3GpD4Epiusmf0UTpM+U0egOjpvi5BvGBGRJmeGzc45weFiN3ZFRmjfpsbE OLIFdBmf4ptwh+vqnICp7REzWvPYtdk+i7PB7Qu7Sx1aZYqJ2UvgIuad8jwTzuOOHHghDj lMUv0W7Kkhmy2AyumE4gJh247ty0I+iFQXgfzdQACwGjb8/tXn5SyHRPVIOfjw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from [IPV6:2601:648:8683:a9e0:d463:68d9:bed3:b37f] (unknown [IPv6:2601:648:8683:a9e0:d463:68d9:bed3:b37f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4RPhh53Jzdz1SK2; Mon, 14 Aug 2023 17:48:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <47f3c866-a469-5b77-c815-6309a136df65@FreeBSD.org> Date: Mon, 14 Aug 2023 10:48:03 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH] Remove alloca from osabi.c Content-Language: en-US To: Tom Tromey , gdb-patches@sourceware.org References: <20230814164820.16355-1-tom@tromey.com> From: John Baldwin In-Reply-To: <20230814164820.16355-1-tom@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 8/14/23 9:48 AM, Tom Tromey wrote: > I noticed that the call to alloca in osabi.c can be replaced with a > statically-sized buffer, because some code just before the declaration > ensures that the length is bounded. > --- > gdb/osabi.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/gdb/osabi.c b/gdb/osabi.c > index d18802ac3a4..ad3dad5b849 100644 > --- a/gdb/osabi.c > +++ b/gdb/osabi.c > @@ -463,7 +463,6 @@ generic_elf_osabi_sniff_abi_tag_sections (bfd *abfd, asection *sect, > { > const char *name; > unsigned int sectsize; > - char *note; > > name = bfd_section_name (sect); > sectsize = bfd_section_size (sect); > @@ -477,7 +476,7 @@ generic_elf_osabi_sniff_abi_tag_sections (bfd *abfd, asection *sect, > compressed section. But, since note sections are not compressed, > deferring the reading until we recognize the section avoids any > error. */ > - note = (char *) alloca (sectsize); > + char note[MAX_NOTESZ]; > > /* .note.ABI-tag notes, used by GNU/Linux and FreeBSD. */ > if (strcmp (name, ".note.ABI-tag") == 0) Reviewed-by: John Baldwin -- John Baldwin