Zebediah Figura : dbghelp: Detect ELF architecture before reading the whole header.
Alexandre Julliard
julliard at winehq.org
Fri Jun 1 18:19:53 CDT 2018
Module: wine
Branch: master
Commit: a612f1f56fefd00ebe6d8f7bcf7c826f5aa85eab
URL: https://source.winehq.org/git/wine.git/?a=commit;h=a612f1f56fefd00ebe6d8f7bcf7c826f5aa85eab
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Thu May 31 17:26:22 2018 -0500
dbghelp: Detect ELF architecture before reading the whole header.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dbghelp/elf_module.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c
index e4689a7..d0b483a 100644
--- a/dlls/dbghelp/elf_module.c
+++ b/dlls/dbghelp/elf_module.c
@@ -307,6 +307,7 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map*
char* filename;
unsigned len;
BOOL ret = FALSE;
+ unsigned char e_ident[EI_NIDENT];
switch (emfd->kind)
{
@@ -340,14 +341,19 @@ static BOOL elf_map_file(struct elf_map_file_data* emfd, struct image_file_map*
case from_process:
break;
}
- if (!elf_map_file_read(fmap, emfd, &fmap->u.elf.elfhdr, sizeof(fmap->u.elf.elfhdr), 0))
+
+ if (!elf_map_file_read(fmap, emfd, e_ident, sizeof(e_ident), 0))
goto done;
/* and check for an ELF header */
- if (memcmp(fmap->u.elf.elfhdr.e_ident,
- elf_signature, sizeof(elf_signature))) goto done;
+ if (memcmp(e_ident, elf_signature, sizeof(elf_signature)))
+ goto done;
+
+ fmap->addr_size = e_ident[EI_CLASS] == ELFCLASS64 ? 64 : 32;
+
+ if (!elf_map_file_read(fmap, emfd, &fmap->u.elf.elfhdr, sizeof(fmap->u.elf.elfhdr), 0))
+ goto done;
- fmap->addr_size = fmap->u.elf.elfhdr.e_ident[EI_CLASS] == ELFCLASS64 ? 64 : 32;
fmap->u.elf.sect = HeapAlloc(GetProcessHeap(), 0,
fmap->u.elf.elfhdr.e_shnum * sizeof(fmap->u.elf.sect[0]));
if (!fmap->u.elf.sect) goto done;
More information about the wine-cvs
mailing list