From 4c3361e39e636eec51c1651460d2b72c4a139007 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Sat, 20 Mar 2010 09:48:13 +0100 Subject: [PATCH] dbghelp: Properly bail out if get an error while reading ELF header. --- dlls/dbghelp/elf_module.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c index 573a04065c..e0fab9c958 100644 --- a/dlls/dbghelp/elf_module.c +++ b/dlls/dbghelp/elf_module.c @@ -272,7 +272,12 @@ static BOOL elf_map_file(const WCHAR* filenameW, struct image_file_map* fmap) lseek(fmap->u.elf.fd, fmap->u.elf.elfhdr.e_shoff, SEEK_SET); for (i = 0; i < fmap->u.elf.elfhdr.e_shnum; i++) { - read(fmap->u.elf.fd, &fmap->u.elf.sect[i].shdr, sizeof(fmap->u.elf.sect[i].shdr)); + if (read(fmap->u.elf.fd, &fmap->u.elf.sect[i].shdr, sizeof(fmap->u.elf.sect[i].shdr)) != sizeof(fmap->u.elf.sect[i].shdr)) + { + HeapFree(GetProcessHeap, 0, fmap->u.elf.sect); + fmap->u.elf.sect = NULL; + goto done; + } fmap->u.elf.sect[i].mapped = IMAGE_NO_MAP; } -- 2.33.8