From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 290933858CDA for ; Tue, 2 Jan 2024 11:21:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 290933858CDA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 290933858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704194510; cv=none; b=DDZsI7CFATqGZAnqTWWm7VcmrCLw9lkzPzVOh+SYpsg6y0b+GPGC4L3693wKX+8a0j12vsug8z+sSSfKIx0xeobewTSUeJf7cc7pWZafKPoULikEZuW141kBE4LoKU0K8rlXnT7tSOhwibeDe2khOaDTHZ6gyHGLapXH0AGkqbQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704194510; c=relaxed/simple; bh=aW09KT8bbdYDk6XqZCdqN1XFv9wQGpcrBeyd4RQiXqU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=M7ZIxeVg2vjdOkqd96DMI3tj5ry5J7su/hBEEp9NiDUN7FFlhfp3tXVkYndFvDSnuRz/m729sTo0ENNKZITgY9fD02q2E69VXaNrpeMJ9ZS9Jcrc0SBC6BcobJyJh46v7GotE7HzYtipJzCE8PvpJ0JV2vmcY/K+BtzCcHQbKYI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704194507; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UmuFYrxRISgPPlwEuywfzeAGr31oZZcyAqmro/ShLNk=; b=fpZ75ffimZ3gJ3Zo3zHzJaPKbI97st6SyghyoXG2mQXd9BMsTv9z11AWVAXCtZhNADkBx6 wqb8xkoJytoW11vtcxknnNkCI4qWT2uMgBgj2lq0QF/feAOyw3HKOu2AwVVH/N6o0/hn0Z Xnr2qeP4wVhJRGsz8ZM+XW7tjxgLjEo= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-693-bhigYaaZO2G2qjjhHfzFtA-1; Tue, 02 Jan 2024 06:21:46 -0500 X-MC-Unique: bhigYaaZO2G2qjjhHfzFtA-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-40d2a286757so54934215e9.1 for ; Tue, 02 Jan 2024 03:21:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704194505; x=1704799305; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UmuFYrxRISgPPlwEuywfzeAGr31oZZcyAqmro/ShLNk=; b=nDwRVI7JjhJWXUuVt/IDir5J8m8vSJO9JEogjNT+YKDHyRWw4sFMP/MVmJacKiNw2V SLJ6rHQvsT1l8KXZGc0m5IhPZKMQF//Od0q5ilAXGcvVq7MKNbnh4iVosFoJ15o001OP 4TMqlaS7MD1+MdzQbrHc40AXeHK0pOQyeFEntDEufehLrTCkZOJ3pkl7SKYUevPA4yuo 2/uE0KkwTXQjlBpvxN+SZrlUOKLbZ3nnibB62Hfpl6UOnDeG/dfVNTin6mdRzzl1+D6T wO+D5emr/Sl5jVQ/lK5NQVcm25Z25dcs7fmNcLtzpdWRo29wJaKdKoWdjm25Lb1LCoGh fV2w== X-Gm-Message-State: AOJu0Yygy46KTUZ7G7Ay3On8dPnhGAhX4vZQW7AdQDCkaDbcmlt6oF2h sjIEhRe/Nf+7fsDslWwsc5EuPqnCCCgpOSxCb35C2t65wAzknz1yJdU7Hedu0MQ2lP0hv9EVmje hT9MsMdZsQTx16CPitpyc4oRznz6gAirNXlLgv+hc/KqlnreC84Dkv9LdjbWCzHZhfZovrjWNq9 q+Ls5RqlLu6Q== X-Received: by 2002:a05:600c:19cb:b0:40d:8636:82f5 with SMTP id u11-20020a05600c19cb00b0040d863682f5mr1752327wmq.122.1704194505001; Tue, 02 Jan 2024 03:21:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IFv8dOs3FtaBJUoGos1bTkPmGZqHlU49rP+n2hv0azt3MLBiHR4Jai59zbsFEJ70/gvg28yAA== X-Received: by 2002:a05:600c:19cb:b0:40d:8636:82f5 with SMTP id u11-20020a05600c19cb00b0040d863682f5mr1752319wmq.122.1704194504613; Tue, 02 Jan 2024 03:21:44 -0800 (PST) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id v4-20020a05600c444400b0040d83ab2ecdsm11722589wmn.21.2024.01.02.03.21.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 03:21:44 -0800 (PST) From: Andrew Burgess To: binutils@sourceware.org Subject: Ping: Re: [PATCH] bfd: make _bfd_section_size_insane part of the public API In-Reply-To: References: Date: Tue, 02 Jan 2024 11:21:43 +0000 Message-ID: <87cyuk9e0o.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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: Ping! Thanks, Andrew Andrew Burgess writes: > If a BFD user is making use of a function like > bfd_get_section_contents to read a section into a pre-allocated > buffer, then that BFD user might also want to make use of > _bfd_section_size_insane prior to allocating the buffer they intend to > use in order to validate that the buffer size that plan to allocate is > sane. > > This commit makes _bfd_section_size_insane public, by renaming it to > bfd_section_size_insane. > > I've updated the existing uses within bfd/, I don't believe this > function is used outside of bfd/ currently. > > One place that I plan to make use of this function is in > gdb/gdb_bfd.c, in the function gdb_bfd_get_full_section_contents. > This change isn't included in this commit, but will come later if/when > this has been merged into bfd. > > There should be no change in behaviour after this commit. > --- > bfd/bfd-in2.h | 2 ++ > bfd/compress.c | 4 ++-- > bfd/dwarf2.c | 4 ++-- > bfd/libbfd.h | 2 -- > bfd/section.c | 8 ++++---- > 5 files changed, 10 insertions(+), 10 deletions(-) > > diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h > index 040d5560cdf..c3ade639ad7 100644 > --- a/bfd/bfd-in2.h > +++ b/bfd/bfd-in2.h > @@ -1088,6 +1088,8 @@ const char *bfd_generic_group_name (bfd *, const asection *sec); > > bool bfd_generic_discard_group (bfd *abfd, asection *group); > > +bool bfd_section_size_insane (bfd *abfd, asection *sec); > + > /* Extracted from syms.c. */ > typedef struct bfd_symbol > { > diff --git a/bfd/compress.c b/bfd/compress.c > index 7ec7b0edf38..17f996f1613 100644 > --- a/bfd/compress.c > +++ b/bfd/compress.c > @@ -735,7 +735,7 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr) > > if (p == NULL > && compress_status != COMPRESS_SECTION_DONE > - && _bfd_section_size_insane (abfd, sec)) > + && bfd_section_size_insane (abfd, sec)) > { > /* PR 24708: Avoid attempts to allocate a ridiculous amount > of memory. */ > @@ -1066,7 +1066,7 @@ bfd_init_section_compress_status (bfd *abfd, sec_ptr sec) > || sec->rawsize != 0 > || sec->contents != NULL > || sec->compress_status != COMPRESS_SECTION_NONE > - || _bfd_section_size_insane (abfd, sec)) > + || bfd_section_size_insane (abfd, sec)) > { > bfd_set_error (bfd_error_invalid_operation); > return false; > diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c > index 22e6b467598..771929a8c28 100644 > --- a/bfd/dwarf2.c > +++ b/bfd/dwarf2.c > @@ -716,7 +716,7 @@ read_section (bfd *abfd, > return false; > } > > - if (_bfd_section_size_insane (abfd, msec)) > + if (bfd_section_size_insane (abfd, msec)) > { > /* PR 26946 */ > _bfd_error_handler (_("DWARF error: section %s is too big"), > @@ -5498,7 +5498,7 @@ _bfd_dwarf2_slurp_debug_info (bfd *abfd, bfd *debug_bfd, > msec; > msec = find_debug_info (debug_bfd, debug_sections, msec)) > { > - if (_bfd_section_size_insane (debug_bfd, msec)) > + if (bfd_section_size_insane (debug_bfd, msec)) > goto restore_vma; > /* Catch PR25070 testcase overflowing size calculation here. */ > if (total_size + msec->size < total_size) > diff --git a/bfd/libbfd.h b/bfd/libbfd.h > index cc432677a81..c7ae249dfea 100644 > --- a/bfd/libbfd.h > +++ b/bfd/libbfd.h > @@ -3641,8 +3641,6 @@ bool _bfd_unrecognized_reloc > unsigned int r_type) ATTRIBUTE_HIDDEN; > > /* Extracted from section.c. */ > -bool _bfd_section_size_insane (bfd *abfd, asection *sec) ATTRIBUTE_HIDDEN; > - > /* Extracted from stabs.c. */ > bool _bfd_link_section_stabs > (bfd *, struct stab_info *, asection *, asection *, void **, > diff --git a/bfd/section.c b/bfd/section.c > index e9af59dfd15..c9e5d3e0b65 100644 > --- a/bfd/section.c > +++ b/bfd/section.c > @@ -1715,11 +1715,11 @@ _bfd_nowrite_set_section_contents (bfd *abfd, > } > > /* > -INTERNAL_FUNCTION > - _bfd_section_size_insane > +FUNCTION > + bfd_section_size_insane > > SYNOPSIS > - bool _bfd_section_size_insane (bfd *abfd, asection *sec); > + bool bfd_section_size_insane (bfd *abfd, asection *sec); > > DESCRIPTION > Returns true if the given section has a size that indicates > @@ -1729,7 +1729,7 @@ DESCRIPTION > */ > > bool > -_bfd_section_size_insane (bfd *abfd, asection *sec) > +bfd_section_size_insane (bfd *abfd, asection *sec) > { > bfd_size_type size = bfd_get_section_limit_octets (abfd, sec); > if (size == 0) > > base-commit: 5a22e042e41db962cd6a79cd59cab46cbbe58a98 > -- > 2.25.4