From 82d26f04a46fd67cead9ef1b8ab721e98449f250 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Tue, 8 Nov 2022 10:30:48 -0800 Subject: [PATCH] p_vmlinx was too eager https://github.com/upx/upx/issues/622 modified: src/p_vmlinx.cpp --- src/p_vmlinx.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/p_vmlinx.cpp b/src/p_vmlinx.cpp index 0039e721..6c664d59 100644 --- a/src/p_vmlinx.cpp +++ b/src/p_vmlinx.cpp @@ -108,7 +108,8 @@ typename T::Shdr const *PackVmlinuxBase::getElfSections() if (ehdri.e_shentsize != sizeof(*shdri) || file_size_u < ehdri.e_shoff || file_size_u < ehdri.e_shoff + mem_size(ehdri.e_shentsize, e_shnum)) { - throwCantPack("bad ElfXX_Shdrs"); + infoWarning("bad ElfXX_Shdrs"); + return nullptr; } shdri = new Shdr[(unsigned) e_shnum]; fi->seek(ehdri.e_shoff, SEEK_SET); @@ -117,7 +118,8 @@ typename T::Shdr const *PackVmlinuxBase::getElfSections() if (e_shnum <= e_shstrndx) { char msg[50]; snprintf(msg, sizeof(msg), "bad .e_shstrndx %#x", e_shstrndx); - throwCantPack(msg); + infoWarning(msg); + return nullptr; } Shdr const *p = &shdri[e_shstrndx]; if (Shdr::SHT_STRTAB==p->sh_type @@ -130,7 +132,8 @@ typename T::Shdr const *PackVmlinuxBase::getElfSections() if (p->sh_size <= p->sh_name) { char msg[50]; snprintf(msg, sizeof(msg), "bad .shstrtab _Shdr[%u]", (unsigned)ehdri.e_shstrndx); - throwCantPack(msg); + infoWarning(msg); + return nullptr; } shstrtab = new char[1+ p->sh_size]; fi->seek(p->sh_offset, SEEK_SET);