0==e_shnum obviates testing of e_shoff
modified: p_lx_elf.cpp
This commit is contained in:
+4
-3
@@ -269,7 +269,7 @@ PackLinuxElf32::PackLinuxElf32help1(InputFile *f)
|
|||||||
e_shoff = get_te32(&ehdri.e_shoff);
|
e_shoff = get_te32(&ehdri.e_shoff);
|
||||||
unsigned const last_Shdr = e_shoff + e_shnum * sizeof(Elf32_Shdr);
|
unsigned const last_Shdr = e_shoff + e_shnum * sizeof(Elf32_Shdr);
|
||||||
if (last_Shdr < e_shoff // wrap-around
|
if (last_Shdr < e_shoff // wrap-around
|
||||||
|| e_shoff < last_Phdr
|
|| (e_shnum && e_shoff < last_Phdr)
|
||||||
|| (unsigned long)file_size < last_Shdr) {
|
|| (unsigned long)file_size < last_Shdr) {
|
||||||
if (opt->cmd == CMD_COMPRESS) {
|
if (opt->cmd == CMD_COMPRESS) {
|
||||||
throwCantUnpack("bad e_shoff");
|
throwCantUnpack("bad e_shoff");
|
||||||
@@ -771,7 +771,7 @@ PackLinuxElf64::PackLinuxElf64help1(InputFile *f)
|
|||||||
e_shoff = get_te64(&ehdri.e_shoff);
|
e_shoff = get_te64(&ehdri.e_shoff);
|
||||||
upx_uint64_t const last_Shdr = e_shoff + e_shnum * sizeof(Elf64_Shdr);
|
upx_uint64_t const last_Shdr = e_shoff + e_shnum * sizeof(Elf64_Shdr);
|
||||||
if (last_Shdr < e_shoff // wrap-around
|
if (last_Shdr < e_shoff // wrap-around
|
||||||
|| e_shoff < last_Phdr
|
|| (e_shnum && e_shoff < last_Phdr)
|
||||||
|| (unsigned long)file_size < last_Shdr) {
|
|| (unsigned long)file_size < last_Shdr) {
|
||||||
if (opt->cmd == CMD_COMPRESS) {
|
if (opt->cmd == CMD_COMPRESS) {
|
||||||
throwCantUnpack("bad e_shoff");
|
throwCantUnpack("bad e_shoff");
|
||||||
@@ -2693,8 +2693,9 @@ PackLinuxElf64::canPack()
|
|||||||
}
|
}
|
||||||
goto proceed; // But proper packing depends on checking xct_va.
|
goto proceed; // But proper packing depends on checking xct_va.
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
throwCantPack("need DT_INIT; try \"void _init(void){}\"");
|
throwCantPack("need DT_INIT; try \"void _init(void){}\"");
|
||||||
|
}
|
||||||
abandon:
|
abandon:
|
||||||
return false;
|
return false;
|
||||||
proceed: ;
|
proceed: ;
|
||||||
|
|||||||
Reference in New Issue
Block a user