|
@@ -875,45 +875,23 @@ static int __check_elf_header (void * fbp, size_t len)
|
|
[EI_CLASS] = ELFW(CLASS),
|
|
[EI_CLASS] = ELFW(CLASS),
|
|
[EI_DATA] = byteorder,
|
|
[EI_DATA] = byteorder,
|
|
[EI_VERSION] = EV_CURRENT,
|
|
[EI_VERSION] = EV_CURRENT,
|
|
- [EI_OSABI] = ELFOSABI_SYSV,
|
|
|
|
- [EI_ABIVERSION] = 0
|
|
|
|
|
|
+ [EI_OSABI] = 0,
|
|
};
|
|
};
|
|
|
|
|
|
/* See whether the ELF header is what we expect. */
|
|
/* See whether the ELF header is what we expect. */
|
|
- if (__builtin_expect (memcmp (ehdr->e_ident, expected, EI_ABIVERSION) !=
|
|
|
|
- 0, 0)) {
|
|
|
|
|
|
+ if (__builtin_expect(memcmp(ehdr->e_ident, expected, EI_OSABI) != 0 ||
|
|
|
|
+ (ehdr->e_ident[EI_OSABI] != ELFOSABI_SYSV &&
|
|
|
|
+ ehdr->e_ident[EI_OSABI] != ELFOSABI_LINUX), 0)) {
|
|
errstring = "ELF file with invalid header";
|
|
errstring = "ELF file with invalid header";
|
|
goto verify_failed;
|
|
goto verify_failed;
|
|
}
|
|
}
|
|
|
|
|
|
- /* Check whether the ELF header use the right endian */
|
|
|
|
- if (ehdr->e_ident[EI_DATA] != byteorder) {
|
|
|
|
- if (__BYTE_ORDER == __BIG_ENDIAN) {
|
|
|
|
- errstring = "ELF file data encoding not big-endian";
|
|
|
|
- goto verify_failed;
|
|
|
|
- } else {
|
|
|
|
- errstring = "ELF file data encoding not little-endian";
|
|
|
|
- goto verify_failed;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /* checking the header is of the right version */
|
|
|
|
- if (ehdr->e_ident[EI_VERSION] != EV_CURRENT) {
|
|
|
|
- errstring = "ELF file version ident does not match current one";
|
|
|
|
- goto verify_failed;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if (memcmp(&ehdr->e_ident[EI_PAD], &expected[EI_PAD],
|
|
if (memcmp(&ehdr->e_ident[EI_PAD], &expected[EI_PAD],
|
|
EI_NIDENT - EI_PAD) != 0) {
|
|
EI_NIDENT - EI_PAD) != 0) {
|
|
errstring = "nonzero padding in e_ident";
|
|
errstring = "nonzero padding in e_ident";
|
|
goto verify_failed;
|
|
goto verify_failed;
|
|
}
|
|
}
|
|
|
|
|
|
- if (__builtin_expect (ehdr->e_version, EV_CURRENT) != EV_CURRENT) {
|
|
|
|
- errstring = "ELF file version does not match current one";
|
|
|
|
- goto verify_failed;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/* Now we check if the host match the elf machine profile */
|
|
/* Now we check if the host match the elf machine profile */
|
|
if (! __builtin_expect (elf_machine_matches_host (ehdr), 1)) {
|
|
if (! __builtin_expect (elf_machine_matches_host (ehdr), 1)) {
|
|
errstring = "ELF file does not match with the host";
|
|
errstring = "ELF file does not match with the host";
|