1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

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
This commit is contained in:
John Reiser 2024-07-02 11:24:27 -07:00 committed by Markus F.X.J. Oberhumer
parent 043a54cf3e
commit 08a38af553

View File

@ -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",