Improved some ELF header checks.
committer: mfx <mfx> 978099239 +0000
This commit is contained in:
+4
-1
@@ -183,8 +183,11 @@ bool PackLinuxI386elf::canPack()
|
|||||||
if (j >= 14)
|
if (j >= 14)
|
||||||
return false;
|
return false;
|
||||||
if (phdr->PT_LOAD == phdr->p_type) {
|
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;
|
return false;
|
||||||
|
}
|
||||||
exetype = 1;
|
exetype = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-2
@@ -95,11 +95,10 @@ int PackLinuxI386::checkEhdr(const Elf_LE32_Ehdr *ehdr) const
|
|||||||
{
|
{
|
||||||
const unsigned char * const buf = ehdr->e_ident;
|
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
|
if (memcmp(buf, "\x7f\x45\x4c\x46\x01\x01\x01", 7)) // ELF 32-bit LSB
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// FIXME: add special checks for uncompresed "vmlinux" kernel
|
|
||||||
// now check the ELF header
|
// now check the ELF header
|
||||||
if (!memcmp(buf+8, "FreeBSD", 7)) // branded
|
if (!memcmp(buf+8, "FreeBSD", 7)) // branded
|
||||||
return 1;
|
return 1;
|
||||||
@@ -109,6 +108,12 @@ int PackLinuxI386::checkEhdr(const Elf_LE32_Ehdr *ehdr) const
|
|||||||
return 3;
|
return 3;
|
||||||
if (ehdr->e_version != 1) // version
|
if (ehdr->e_version != 1) // version
|
||||||
return 4;
|
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
|
// success
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user