From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: debug_link duplicate file size checks
Date: Wed, 22 Feb 2023 09:29:15 +1030 [thread overview]
Message-ID: <Y/VMwx4rDcB3csbz@squeak.grove.modra.org> (raw)
bfd_malloc_and_get_section does these checks.
* opncls.c (bfd_get_debug_link_info_1): Don't check section
size against file size.
(bfd_get_alt_debug_link_info): Likewise.
diff --git a/bfd/opncls.c b/bfd/opncls.c
index 5dacad9b7d4..cdf09b333fa 100644
--- a/bfd/opncls.c
+++ b/bfd/opncls.c
@@ -1195,7 +1195,6 @@ bfd_get_debug_link_info_1 (bfd *abfd, void *crc32_out)
unsigned int crc_offset;
char *name;
bfd_size_type size;
- ufile_ptr file_size;
BFD_ASSERT (abfd);
BFD_ASSERT (crc32_out);
@@ -1206,10 +1205,9 @@ bfd_get_debug_link_info_1 (bfd *abfd, void *crc32_out)
return NULL;
size = bfd_section_size (sect);
- file_size = bfd_get_size (abfd);
/* PR 22794: Make sure that the section has a reasonable size. */
- if (size < 8 || (file_size != 0 && size >= file_size))
+ if (size < 8)
return NULL;
if (!bfd_malloc_and_get_section (abfd, sect, &contents))
@@ -1284,7 +1282,6 @@ bfd_get_alt_debug_link_info (bfd * abfd, bfd_size_type *buildid_len,
unsigned int buildid_offset;
char *name;
bfd_size_type size;
- ufile_ptr file_size;
BFD_ASSERT (abfd);
BFD_ASSERT (buildid_len);
@@ -1296,8 +1293,7 @@ bfd_get_alt_debug_link_info (bfd * abfd, bfd_size_type *buildid_len,
return NULL;
size = bfd_section_size (sect);
- file_size = bfd_get_size (abfd);
- if (size < 8 || (file_size != 0 && size >= file_size))
+ if (size < 8)
return NULL;
if (!bfd_malloc_and_get_section (abfd, sect, & contents))
--
Alan Modra
Australia Development Lab, IBM
reply other threads:[~2023-02-21 22:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=Y/VMwx4rDcB3csbz@squeak.grove.modra.org \
--to=amodra@gmail.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).