Require DT_STRSZ
https://github.com/upx/upx/issues/512 modified: p_lx_elf.cpp
This commit is contained in:
committed by
Markus F.X.J. Oberhumer
parent
294a7077de
commit
fdc5d25d03
+11
-14
@@ -1646,13 +1646,11 @@ PackLinuxElf32::invert_pt_dynamic(Elf32_Dyn const *dynp, unsigned headway)
|
|||||||
else if (dt_table[Elf32_Dyn::DT_INIT_ARRAY]) upx_dt_init = Elf32_Dyn::DT_INIT_ARRAY;
|
else if (dt_table[Elf32_Dyn::DT_INIT_ARRAY]) upx_dt_init = Elf32_Dyn::DT_INIT_ARRAY;
|
||||||
|
|
||||||
unsigned const z_str = dt_table[Elf32_Dyn::DT_STRSZ];
|
unsigned const z_str = dt_table[Elf32_Dyn::DT_STRSZ];
|
||||||
if (z_str) {
|
strtab_end = !z_str ? 0 : get_te64(&dynp0[-1+ z_str].d_val);
|
||||||
strtab_end = get_te32(&dynp0[-1+ z_str].d_val);
|
if (!z_str || (u64_t)file_size <= strtab_end) { // FIXME: weak
|
||||||
if ((u32_t)file_size <= strtab_end) { // FIXME: weak
|
char msg[50]; snprintf(msg, sizeof(msg),
|
||||||
char msg[50]; snprintf(msg, sizeof(msg),
|
"bad DT_STRSZ %#x", strtab_end);
|
||||||
"bad DT_STRSZ %#x", strtab_end);
|
throwCantPack(msg);
|
||||||
throwCantPack(msg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
unsigned const x_sym = dt_table[Elf32_Dyn::DT_SYMTAB];
|
unsigned const x_sym = dt_table[Elf32_Dyn::DT_SYMTAB];
|
||||||
unsigned const x_str = dt_table[Elf32_Dyn::DT_STRTAB];
|
unsigned const x_str = dt_table[Elf32_Dyn::DT_STRTAB];
|
||||||
@@ -5507,14 +5505,13 @@ PackLinuxElf64::invert_pt_dynamic(Elf64_Dyn const *dynp, upx_uint64_t headway)
|
|||||||
else if (dt_table[Elf64_Dyn::DT_INIT_ARRAY]) upx_dt_init = Elf64_Dyn::DT_INIT_ARRAY;
|
else if (dt_table[Elf64_Dyn::DT_INIT_ARRAY]) upx_dt_init = Elf64_Dyn::DT_INIT_ARRAY;
|
||||||
|
|
||||||
unsigned const z_str = dt_table[Elf64_Dyn::DT_STRSZ];
|
unsigned const z_str = dt_table[Elf64_Dyn::DT_STRSZ];
|
||||||
if (z_str) {
|
strtab_end = !z_str ? 0 : get_te64(&dynp0[-1+ z_str].d_val);
|
||||||
strtab_end = get_te64(&dynp0[-1+ z_str].d_val);
|
if (!z_str || (u64_t)file_size <= strtab_end) { // FIXME: weak
|
||||||
if ((u64_t)file_size <= strtab_end) { // FIXME: weak
|
char msg[50]; snprintf(msg, sizeof(msg),
|
||||||
char msg[50]; snprintf(msg, sizeof(msg),
|
"bad DT_STRSZ %#x", strtab_end);
|
||||||
"bad DT_STRSZ %#x", strtab_end);
|
throwCantPack(msg);
|
||||||
throwCantPack(msg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DT_SYMTAB has no designated length.
|
// DT_SYMTAB has no designated length.
|
||||||
// End it when next area else starts; often DT_STRTAB. (FIXME)
|
// End it when next area else starts; often DT_STRTAB. (FIXME)
|
||||||
unsigned const x_sym = dt_table[Elf64_Dyn::DT_SYMTAB];
|
unsigned const x_sym = dt_table[Elf64_Dyn::DT_SYMTAB];
|
||||||
|
|||||||
Reference in New Issue
Block a user