From: Jon Turney Date: Thu, 2 Jan 2020 00:25:56 +0000 (+0000) Subject: Fix a crash with a malformed PE header X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a08c904d4e9688a869242d9cec1b64ca23b1214e;p=binutils-gdb.git Fix a crash with a malformed PE header Don't try to read the PE export table when no section contains the RVA for it. (I have a PE executable [1] packed with UPX, where the export table data directory entry contains a RVA which doesn't correspond to any section. Mistakenly trying to debug this with gdb makes it crash.) [1] https://cygwin.com/setup/setup-2.898.x86_64.exe gdb/ChangeLog: 2020-01-02 Jon Turney * coff-pe-read.c (read_pe_exported_syms): Don't try to read the export table if no section contains it's RVA. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 177b50542ef..9a3cca2a127 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-01-02 Jon Turney + + * coff-pe-read.c (read_pe_exported_syms): Don't try to read the + export table if no section contains it's RVA. + 2020-01-06 Eli Zaretskii * windows-tdep.c: Fix a typo in WINDOWS_SIGABRT. diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c index e1c51d45e38..d0c1e050c89 100644 --- a/gdb/coff-pe-read.c +++ b/gdb/coff-pe-read.c @@ -441,6 +441,12 @@ read_pe_exported_syms (minimal_symbol_reader &reader, } } + if (expptr == 0) + { + /* no section contains export table rva */ + return; + } + export_rva = export_opthdrrva; export_size = export_opthdrsize;