From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: PR28763, SIGSEGV during processing of program headers via readelf
Date: Wed, 9 Feb 2022 22:31:42 +1030 [thread overview]
Message-ID: <YgOtJrdjaIG7zmsS@squeak.grove.modra.org> (raw)
PR 28763
* readelf.c (process_file_header): Discard any cached program
headers if there is an extension field for e_phnum in first
section header.
diff --git a/binutils/readelf.c b/binutils/readelf.c
index e56e9b56393..b208db59334 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -5631,10 +5631,7 @@ process_file_header (Filedata * filedata)
if (filedata->section_headers != NULL
&& header->e_phnum == PN_XNUM
&& filedata->section_headers[0].sh_info != 0)
- {
- header->e_phnum = filedata->section_headers[0].sh_info;
- printf (" (%u)", header->e_phnum);
- }
+ printf (" (%u)", filedata->section_headers[0].sh_info);
putc ('\n', stdout);
printf (_(" Size of section headers: %u (bytes)\n"),
header->e_shentsize);
@@ -5667,7 +5664,12 @@ process_file_header (Filedata * filedata)
{
if (header->e_phnum == PN_XNUM
&& filedata->section_headers[0].sh_info != 0)
- header->e_phnum = filedata->section_headers[0].sh_info;
+ {
+ /* Throw away any cached read of PN_XNUM headers. */
+ free (filedata->program_headers);
+ filedata->program_headers = NULL;
+ header->e_phnum = filedata->section_headers[0].sh_info;
+ }
if (header->e_shnum == SHN_UNDEF)
header->e_shnum = filedata->section_headers[0].sh_size;
if (header->e_shstrndx == (SHN_XINDEX & 0xffff))
--
Alan Modra
Australia Development Lab, IBM
reply other threads:[~2022-02-09 12:01 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=YgOtJrdjaIG7zmsS@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).