From 69a583281f21ee439943807c8c7bf07efee97cfb Mon Sep 17 00:00:00 2001 From: John Reiser Date: Sun, 16 Dec 2018 16:00:15 -0800 Subject: [PATCH] MemBuffer::subref() for 64-bit offsets; better diagnosis for bad .e_shoff https://github.com/upx/upx/issues/235 (POC14) modified: mem.cpp modified: mem.h modified: p_lx_elf.cpp --- src/p_lx_elf.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index 2f84062f..e81e5c0b 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -4248,6 +4248,7 @@ void PackLinuxElf64::unpack(OutputFile *fo) overlay_offset -= sizeof(linfo); xct_off = overlay_offset; e_shoff = get_te64(&ehdri.e_shoff); + ibuf.subref("bad .e_shoff %#lx for %#lx", e_shoff, sizeof(Elf64_Shdr) * e_shnum); if (e_shoff && e_shnum) { // --android-shlib shdri = (Elf64_Shdr /*const*/ *)ibuf.subref( "bad Shdr table", e_shoff, sizeof(Elf64_Shdr)*e_shnum); @@ -5125,6 +5126,7 @@ void PackLinuxElf32::unpack(OutputFile *fo) overlay_offset -= sizeof(linfo); xct_off = overlay_offset; e_shoff = get_te32(&ehdri.e_shoff); + ibuf.subref("bad .e_shoff %#x for %#x", e_shoff, sizeof(Elf32_Shdr) * e_shnum); if (e_shoff && e_shnum) { // --android-shlib shdri = (Elf32_Shdr /*const*/ *)ibuf.subref( "bad Shdr table", e_shoff, sizeof(Elf32_Shdr)*e_shnum);