mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Improved some ELF header checks.
committer: mfx <mfx> 978099239 +0000
This commit is contained in:
parent
65ad79d727
commit
11ee8627b8
|
@ -183,8 +183,11 @@ bool PackLinuxI386elf::canPack()
|
|||
if (j >= 14)
|
||||
return false;
|
||||
if (phdr->PT_LOAD == phdr->p_type) {
|
||||
if (phdr->p_offset!=0)
|
||||
if (phdr->p_offset != 0)
|
||||
{
|
||||
throwCantPack("invalid Phdr p_offset; try `--force-execve'");
|
||||
return false;
|
||||
}
|
||||
exetype = 1;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -95,11 +95,10 @@ int PackLinuxI386::checkEhdr(const Elf_LE32_Ehdr *ehdr) const
|
|||
{
|
||||
const unsigned char * const buf = ehdr->e_ident;
|
||||
|
||||
// NOTE: ELF executables are now handled by p_lx_elf.cpp.
|
||||
// info: ELF executables are now handled by p_lx_elf.cpp
|
||||
if (memcmp(buf, "\x7f\x45\x4c\x46\x01\x01\x01", 7)) // ELF 32-bit LSB
|
||||
return -1;
|
||||
|
||||
// FIXME: add special checks for uncompresed "vmlinux" kernel
|
||||
// now check the ELF header
|
||||
if (!memcmp(buf+8, "FreeBSD", 7)) // branded
|
||||
return 1;
|
||||
|
@ -109,6 +108,12 @@ int PackLinuxI386::checkEhdr(const Elf_LE32_Ehdr *ehdr) const
|
|||
return 3;
|
||||
if (ehdr->e_version != 1) // version
|
||||
return 4;
|
||||
if (ehdr->e_phnum < 1)
|
||||
return 5;
|
||||
|
||||
// FIXME: add special checks for uncompresed "vmlinux" kernel
|
||||
// FIXME: add special checks for other ELF i386 formats, like
|
||||
// NetBSD, OpenBSD, Solaris, ....
|
||||
|
||||
// success
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user