Skip to content
Permalink
Browse files Browse the repository at this point in the history
PackLinuxElf::canUnpack must checkEhdr() for ELF input
#485
	modified:   p_lx_elf.cpp
  • Loading branch information
jreiser committed Apr 10, 2021
1 parent 28e761c commit 90279ab
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/p_lx_elf.cpp
Expand Up @@ -1971,12 +1971,16 @@ bool PackLinuxElf32::calls_crt1(Elf32_Rel const *rel, int sz)

int PackLinuxElf32::canUnpack()
{
if (super::canUnpack()) {
return true;
if (checkEhdr(&ehdri)) {
return false;
}
// FIXME: ET_DYN same as 64-bit canUnpack ??
if (Elf32_Ehdr::ET_DYN==get_te16(&ehdri.e_type)) {
PackLinuxElf32help1(fi);
}
if (super::canUnpack()) {
return true;
}
return false;
}

Expand Down Expand Up @@ -2396,8 +2400,8 @@ proceed: ;

int PackLinuxElf64::canUnpack()
{
if (super::canUnpack()) {
return true;
if (checkEhdr(&ehdri)) {
return false;
}
if (Elf64_Ehdr::ET_DYN==get_te16(&ehdri.e_type)) {
PackLinuxElf64help1(fi);
Expand All @@ -2413,7 +2417,13 @@ int PackLinuxElf64::canUnpack()
fi->seek(filesz+offset, SEEK_SET);
MemBuffer buf(32 + sizeof(overlay_offset));
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;
}
Expand Down

0 comments on commit 90279ab

Please sign in to comment.