public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Andrew Burgess <aburgess@redhat.com>
Cc: binutils@sourceware.org
Subject: Re: [PATCH] bfd: make _bfd_section_size_insane part of the public API
Date: Fri, 5 Jan 2024 13:03:50 +0100	[thread overview]
Message-ID: <0c54069e-d907-4f03-8d7f-15374d4bfd6a@suse.com> (raw)
In-Reply-To: <b9ff0c22bf79023edc29f8f661b683542b771cb2.1701879297.git.aburgess@redhat.com>

On 06.12.2023 17:15, Andrew Burgess wrote:
> 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.

Having seen your ping (and no other response), let me share my view:
This function implements a certain policy, internal to the library.
By exposing it, you would make external users dependent upon this
specific policy. What if later we change our view on what's "insane"?
IOW external consumers want to implement their own, independent policy
(if so desired).

Taking your intended usage example, things would be different if e.g.
bfd_get_full_section_contents() itself used this check unconditionally.
Then I could see a desire to have a way of checking up front whether
allocating a buffer makes sense at all. And really I consider it
questionable for bfd_get_full_section_contents(), when asked to
allocate a buffer, to actually enforce such a library-internal policy.
Like with exposing bfd_section_size_insane(), any change to the policy
may affect external users in unexpected ways.

Jan

  parent reply	other threads:[~2024-01-05 12:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-06 16:15 Andrew Burgess
2024-01-02 11:21 ` Ping: " Andrew Burgess
2024-01-05 12:03 ` Jan Beulich [this message]
2024-01-10 11:03   ` Andrew Burgess
2024-01-10 12:47     ` Jan Beulich
2024-01-10 13:48       ` Andrew Burgess
2024-01-10 14:26         ` Jan Beulich
2024-01-10 16:20           ` Andrew Burgess
2024-01-10 21:22             ` Alan Modra
2024-01-11  8:23             ` Jan Beulich
2024-03-06 11:17               ` Andrew Burgess
2024-03-06 11:30                 ` Jan Beulich
2024-03-25 18:33                   ` Andrew Burgess
2024-01-10 17:54   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0c54069e-d907-4f03-8d7f-15374d4bfd6a@suse.com \
    --to=jbeulich@suse.com \
    --cc=aburgess@redhat.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).