forked from Imagelibrary/binutils-gdb
readelf: DO not load section headers from file offset zero
* readelf.c (get_32bit_section_headers): Return false if the e_shoff field is zero. (get_64bit_section_headers): Likewise.
This commit is contained in:
@@ -6365,6 +6365,13 @@ get_32bit_section_headers (Filedata * filedata, bool probe)
|
||||
/* PR binutils/17531: Cope with unexpected section header sizes. */
|
||||
if (size == 0 || num == 0)
|
||||
return false;
|
||||
|
||||
/* The section header cannot be at the start of the file - that is
|
||||
where the ELF file header is located. A file with absolutely no
|
||||
sections in it will use a shoff of 0. */
|
||||
if (filedata->file_header.e_shoff == 0)
|
||||
return false;
|
||||
|
||||
if (size < sizeof * shdrs)
|
||||
{
|
||||
if (! probe)
|
||||
@@ -6429,6 +6436,12 @@ get_64bit_section_headers (Filedata * filedata, bool probe)
|
||||
if (size == 0 || num == 0)
|
||||
return false;
|
||||
|
||||
/* The section header cannot be at the start of the file - that is
|
||||
where the ELF file header is located. A file with absolutely no
|
||||
sections in it will use a shoff of 0. */
|
||||
if (filedata->file_header.e_shoff == 0)
|
||||
return false;
|
||||
|
||||
if (size < sizeof * shdrs)
|
||||
{
|
||||
if (! probe)
|
||||
|
||||
Reference in New Issue
Block a user