Skip to content

Commit

Permalink
Avoid segfaults on MS-Windows when invoking subprocesses (Bug#20264)
Browse files Browse the repository at this point in the history
 src/w32proc.c (w32_executable_type): Look for the DLL name in the
 correct section.  This avoids segfaults with some executables.
  • Loading branch information
K-Arakawa authored and Eli-Zaretskii committed Apr 6, 2015
1 parent 7471fc4 commit eedff18
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2015-04-06 Koichi Arakawa <arakawa@pp.iij4u.or.jp> (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 <jan.h.d@swipnet.se>

* xselect.c (x_reply_selection_request)
Expand Down
21 changes: 11 additions & 10 deletions src/w32proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit eedff18

Please sign in to comment.