From 08a38af5538e4879d8fac43caa53946f533ab35a Mon Sep 17 00:00:00 2001 From: John Reiser Date: Tue, 2 Jul 2024 11:24:27 -0700 Subject: [PATCH] Workaround bug in Alpine Linux "empty" DT_GNU_HASH lacked hasharr[0] when n_bucket==1, which upx correctly detected as malformed. modified: p_lx_elf.cpp --- src/p_lx_elf.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index 6064dbd5..b5773871 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -2256,7 +2256,7 @@ PackLinuxElf32::invert_pt_dynamic(Elf32_Dyn const *dynp, u32_t headway) || (r=6, ((v_gsh < v_sym) && (v_sym - v_gsh) < (sizeof(unsigned)*4 // headers + sizeof(*bitmask)*n_bitmask // bitmask + sizeof(*buckets)*n_bucket // buckets - + sizeof(*hasharr)*(1+ bmax) // hasharr + + sizeof(*hasharr)*(!bmax ? 0 : (1+ bmax)) // hasharr )) ) ) { char msg[90]; snprintf(msg, sizeof(msg), @@ -8117,7 +8117,7 @@ PackLinuxElf64::invert_pt_dynamic(Elf64_Dyn const *dynp, upx_uint64_t headway) || (r=6, ((v_gsh < v_sym) && (v_sym - v_gsh) < (sizeof(unsigned)*4 // headers + sizeof(*bitmask)*n_bitmask // bitmask + sizeof(*buckets)*n_bucket // buckets - + sizeof(*hasharr)*(1+ bmax) // hasharr + + sizeof(*hasharr)*(!bmax ? 0 : (1+ bmax)) // hasharr )) ) ) { throwCantPack("bad DT_GNU_HASH n_bucket=%#x n_bitmask=%#x len=%#lx r=%d",