https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7adbd03d5fcd936e93a939...
commit 7adbd03d5fcd936e93a939240b131ba487605b4b Author: winesync ros-dev@reactos.org AuthorDate: Fri Sep 11 13:00:07 2020 +0200 Commit: Jérôme Gardou jerome.gardou@reactos.org CommitDate: Wed Sep 16 10:35:31 2020 +0200
[WINESYNC] dbghelp: Detect ELF architecture before reading the whole header.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
wine commit id a612f1f56fefd00ebe6d8f7bcf7c826f5aa85eab by Zebediah Figura zfigura@codeweavers.com --- dll/win32/dbghelp/elf_module.c | 14 ++++++++++---- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index e4689a71b1e..d0b483abbcf 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/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; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index e58d3a96f88..95dc6bc4fb4 100644 --- a/sdk/tools/winesync/dbghelp.cfg +++ b/sdk/tools/winesync/dbghelp.cfg @@ -3,4 +3,4 @@ directories: files: include/dbghelp.h: sdk/include/psdk/dbghelp.h tags: - wine: c2c0e4fe510f75c757e5dbdc1b727a7c9f3d6f33 + wine: a612f1f56fefd00ebe6d8f7bcf7c826f5aa85eab