PackLinuxElf::canUnpack must checkEhdr() for ELF input
https://github.com/upx/upx/issues/485 modified: p_lx_elf.cpp
This commit is contained in:
committed by
Markus F.X.J. Oberhumer
parent
bf957f435e
commit
be050693f2
+15
-5
@@ -1971,12 +1971,16 @@ bool PackLinuxElf32::calls_crt1(Elf32_Rel const *rel, int sz)
|
|||||||
|
|
||||||
int PackLinuxElf32::canUnpack()
|
int PackLinuxElf32::canUnpack()
|
||||||
{
|
{
|
||||||
if (super::canUnpack()) {
|
if (checkEhdr(&ehdri)) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
// FIXME: ET_DYN same as 64-bit canUnpack ??
|
||||||
if (Elf32_Ehdr::ET_DYN==get_te16(&ehdri.e_type)) {
|
if (Elf32_Ehdr::ET_DYN==get_te16(&ehdri.e_type)) {
|
||||||
PackLinuxElf32help1(fi);
|
PackLinuxElf32help1(fi);
|
||||||
}
|
}
|
||||||
|
if (super::canUnpack()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2396,8 +2400,8 @@ proceed: ;
|
|||||||
|
|
||||||
int PackLinuxElf64::canUnpack()
|
int PackLinuxElf64::canUnpack()
|
||||||
{
|
{
|
||||||
if (super::canUnpack()) {
|
if (checkEhdr(&ehdri)) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
if (Elf64_Ehdr::ET_DYN==get_te16(&ehdri.e_type)) {
|
if (Elf64_Ehdr::ET_DYN==get_te16(&ehdri.e_type)) {
|
||||||
PackLinuxElf64help1(fi);
|
PackLinuxElf64help1(fi);
|
||||||
@@ -2413,7 +2417,13 @@ int PackLinuxElf64::canUnpack()
|
|||||||
fi->seek(filesz+offset, SEEK_SET);
|
fi->seek(filesz+offset, SEEK_SET);
|
||||||
MemBuffer buf(32 + sizeof(overlay_offset));
|
MemBuffer buf(32 + sizeof(overlay_offset));
|
||||||
fi->readx(buf, buf.getSize());
|
fi->readx(buf, buf.getSize());
|
||||||
return PackUnix::find_overlay_offset(buf);
|
unsigned x = PackUnix::find_overlay_offset(buf);
|
||||||
|
if (x) {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (super::canUnpack()) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user