From b78ee5736d93d7fa3476a69cc11229c047f477ec Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Thu, 2 Jan 2020 00:25:56 +0000 Subject: [PATCH] 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 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. --- gdb/ChangeLog | 5 +++++ gdb/coff-pe-read.c | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c index b05357bb8b..926db57e58 100644 --- a/gdb/coff-pe-read.c +++ b/gdb/coff-pe-read.c @@ -441,6 +441,15 @@ read_pe_exported_syms (minimal_symbol_reader &reader, } } + if (expptr == 0) + { + if (debug_coff_pe_read) + fprintf_unfiltered (gdb_stdlog, _("No section contains export RVA for " + "dll \"%s\"\n"), + dll_name); + return; + } + export_rva = export_opthdrrva; export_size = export_opthdrsize; -- 2.21.0