From: Koichi Arakawa Date: Mon, 6 Apr 2015 10:26:54 +0000 (+0300) Subject: Avoid segfaults on MS-Windows when invoking subprocesses (Bug#20264) X-Git-Tag: emacs-25.0.90~2548 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=eedff18424041188c843fb8e183b686df6c217f2;p=emacs.git Avoid segfaults on MS-Windows when invoking subprocesses (Bug#20264) src/w32proc.c (w32_executable_type): Look for the DLL name in the correct section. This avoids segfaults with some executables. --- diff --git a/src/ChangeLog b/src/ChangeLog index 1c3f933d7d8..33d0b9b9521 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2015-04-06 Koichi Arakawa (tiny change) + + * w32proc.c (w32_executable_type): Look for the DLL name in the + correct section. This avoids segfaults with some executables. + (Bug#20264) + 2015-04-04 Jan Djärv * xselect.c (x_reply_selection_request) diff --git a/src/w32proc.c b/src/w32proc.c index 7d982f831e2..9f699ccf65b 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -1613,24 +1613,25 @@ w32_executable_type (char * filename, #endif if (data_dir) { - /* Look for cygwin.dll in DLL import list. */ + /* Look for Cygwin DLL in the DLL import list. */ IMAGE_DATA_DIRECTORY import_dir = data_dir[IMAGE_DIRECTORY_ENTRY_IMPORT]; - IMAGE_IMPORT_DESCRIPTOR * imports; - IMAGE_SECTION_HEADER * section; - - section = rva_to_section (import_dir.VirtualAddress, nt_header); - imports = RVA_TO_PTR (import_dir.VirtualAddress, section, - executable); + IMAGE_IMPORT_DESCRIPTOR * imports = + RVA_TO_PTR (import_dir.VirtualAddress, + rva_to_section (import_dir.VirtualAddress, + nt_header), + executable); for ( ; imports->Name; imports++) { + IMAGE_SECTION_HEADER * section = + rva_to_section (imports->Name, nt_header); char * dllname = RVA_TO_PTR (imports->Name, section, executable); - /* The exact name of the cygwin dll has changed with - various releases, but hopefully this will be reasonably - future proof. */ + /* The exact name of the Cygwin DLL has changed with + various releases, but hopefully this will be + reasonably future-proof. */ if (strncmp (dllname, "cygwin", 6) == 0) { *is_cygnus_app = TRUE;