* PR28763, SIGSEGV during processing of program headers via readelf
@ 2022-02-09 12:01 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2022-02-09 12:01 UTC (permalink / raw)
To: binutils
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-02-09 12:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09 12:01 PR28763, SIGSEGV during processing of program headers via readelf Alan Modra
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).