From 10807ebdc212c44db366131e71b3e358643eae51 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Thu, 25 Jan 2024 09:06:46 -0800 Subject: [PATCH] Unpack 8-byte b_info only if (ph.version <= 11): 2001 or earlier *x86 only: .e_entry too low https://github.com/upx/upx/issues/774 modified: p_lx_elf.cpp --- src/p_lx_elf.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index c7541ab7..80f61a33 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -7170,7 +7170,10 @@ void PackLinuxElf64::unpack(OutputFile *fo) upx_uint64_t old_dtinit = 0; if (Elf64_Ehdr::ET_EXEC == get_te16(&ehdri.e_type)) { - if (get_te64(&ehdri.e_entry) < 0x401180 +// 40fddf17153ee3db73a04ff1bf288b91676138d6 2001-02-01 ph.version 11; b_info 12 bytes +// df9db96bd1c013c07da1d7ec740021d588ab2815 2001-01-17 ph.version 11; no b_info (==> 8 bytes) + if (ph.version <= 11 + && get_te64(&ehdri.e_entry) < 0x401180 && get_te16(&ehdri.e_machine)==Elf64_Ehdr::EM_X86_64) { // old style, 8-byte b_info: // sizeof(b_info.sz_unc) + sizeof(b_info.sz_cpr); @@ -8338,7 +8341,10 @@ void PackLinuxElf32::unpack(OutputFile *fo) upx_uint32_t old_dtinit = 0; if (Elf32_Ehdr::ET_EXEC == get_te16(&ehdri.e_type)) { - if (get_te32(&ehdri.e_entry) < 0x401180 +// 40fddf17153ee3db73a04ff1bf288b91676138d6 2001-02-01 ph.version 11; b_info 12 bytes +// df9db96bd1c013c07da1d7ec740021d588ab2815 2001-01-17 ph.version 11; no b_info (==> 8 bytes) + if (ph.version <= 11 + && get_te32(&ehdri.e_entry) < 0x401180 && get_te16(&ehdri.e_machine)==Elf32_Ehdr::EM_386) { // old style, 8-byte b_info: // sizeof(b_info.sz_unc) + sizeof(b_info.sz_cpr);