More portable signature check.
This commit is contained in:
parent
cacbe216eb
commit
9c54cfa56a
|
@ -1192,6 +1192,7 @@ static enum DbgInfoLoad DEBUG_ProcessElfFile(const char* filename,
|
||||||
unsigned int load_offset,
|
unsigned int load_offset,
|
||||||
unsigned int* dyn_addr)
|
unsigned int* dyn_addr)
|
||||||
{
|
{
|
||||||
|
static const unsigned char elf_signature[4] = { 0x7f, 'E', 'L', 'F' };
|
||||||
enum DbgInfoLoad dil = DIL_ERROR;
|
enum DbgInfoLoad dil = DIL_ERROR;
|
||||||
char* addr = (char*)0xffffffff;
|
char* addr = (char*)0xffffffff;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
@ -1229,7 +1230,7 @@ static enum DbgInfoLoad DEBUG_ProcessElfFile(const char* filename,
|
||||||
* table.
|
* table.
|
||||||
*/
|
*/
|
||||||
ehptr = (Elf32_Ehdr*) addr;
|
ehptr = (Elf32_Ehdr*) addr;
|
||||||
if (memcmp( ehptr->e_ident, ELFMAG, SELFMAG )) goto leave;
|
if (memcmp( ehptr->e_ident, elf_signature, sizeof(elf_signature) )) goto leave;
|
||||||
|
|
||||||
spnt = (Elf32_Shdr*) (addr + ehptr->e_shoff);
|
spnt = (Elf32_Shdr*) (addr + ehptr->e_shoff);
|
||||||
shstrtab = (addr + spnt[ehptr->e_shstrndx].sh_offset);
|
shstrtab = (addr + spnt[ehptr->e_shstrndx].sh_offset);
|
||||||
|
|
Loading…
Reference in New Issue