aboutsummaryrefslogtreecommitdiff
path: root/binutils/readelf.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2017-11-30 10:25:01 +0000
committerNick Clifton <nickc@redhat.com>2017-11-30 10:25:01 +0000
commitf425ec6600b69e39eb605f3128806ff688137ea8 (patch)
treed23913f111758af5cfb8cd4d412ae2432a29baf1 /binutils/readelf.c
parente8020e54f4b9ac05150c4b02fa81e228d6cf1f6a (diff)
downloadbinutils-f425ec6600b69e39eb605f3128806ff688137ea8.zip
binutils-f425ec6600b69e39eb605f3128806ff688137ea8.tar.gz
binutils-f425ec6600b69e39eb605f3128806ff688137ea8.tar.bz2
Prevent an illegal memory access in readelf when attempting to parse a corrupt ELF file.
PR 22510 * readelf.c (load_debug_section): Fail if there are no section headers available.
Diffstat (limited to 'binutils/readelf.c')
-rw-r--r--binutils/readelf.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/binutils/readelf.c b/binutils/readelf.c
index a1f43e6..e0230c7 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -13574,6 +13574,10 @@ load_debug_section (enum dwarf_section_display_enum debug, void * data)
Elf_Internal_Shdr * sec;
Filedata * filedata = (Filedata *) data;
+ /* Without section headers we cannot find any sections. */
+ if (filedata->section_headers == NULL)
+ return FALSE;
+
if (filedata->string_table == NULL)
{
Elf_Internal_Shdr * strs;