[newlib-cygwin] Fix potential hang in ldd if DLL encounters missing entry point

Corinna Vinschen corinna@sourceware.org
Mon Jul 20 16:32:00 GMT 2015


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=23ad79d7de0a3ff47ad211347340b7c6750caedc

commit 23ad79d7de0a3ff47ad211347340b7c6750caedc
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Mon Jul 20 18:32:24 2015 +0200

    Fix potential hang in ldd if DLL encounters missing entry point
    
             * ldd.cc (STATUS_DLL_NOT_FOUND): Drop definition.
            (report): Handle STATUS_ENTRYPOINT_NOT_FOUND exception.  Explain why.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/utils/ChangeLog |  5 +++++
 winsup/utils/ldd.cc    | 10 ++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog
index db6049b..bc8835f 100644
--- a/winsup/utils/ChangeLog
+++ b/winsup/utils/ChangeLog
@@ -1,3 +1,8 @@
+2015-07-20  Corinna Vinschen  <corinna@vinschen.de>
+
+	* ldd.cc (STATUS_DLL_NOT_FOUND): Drop definition.
+	(report): Handle STATUS_ENTRYPOINT_NOT_FOUND exception.  Explain why.
+
 2015-07-08  Corinna Vinschen  <corinna@vinschen.de>
 
 	* tzset.c (main): Check timezone and country case-insensitive.
diff --git a/winsup/utils/ldd.cc b/winsup/utils/ldd.cc
index de98658..e4c14b4 100644
--- a/winsup/utils/ldd.cc
+++ b/winsup/utils/ldd.cc
@@ -42,10 +42,6 @@
 #include <imagehlp.h>
 #include <psapi.h>
 
-#ifndef STATUS_DLL_NOT_FOUND
-#define STATUS_DLL_NOT_FOUND (0xC0000135L)
-#endif
-
 struct option longopts[] =
 {
   {"help", no_argument, NULL, 'h'},
@@ -346,6 +342,11 @@ report (const char *in_fn, bool multiple)
 	case EXCEPTION_DEBUG_EVENT:
 	  switch (ev.u.Exception.ExceptionRecord.ExceptionCode)
 	    {
+	    case STATUS_ENTRYPOINT_NOT_FOUND:
+	      /* A STATUS_ENTRYPOINT_NOT_FOUND might be encountered right after
+		 loading all DLLs.  We have to handle it here, otherwise ldd
+		 runs into an endless loop. */
+	      goto print_and_exit;
 	    case STATUS_DLL_NOT_FOUND:
 	      process_fn = fn_win;
 	      break;
@@ -359,6 +360,7 @@ report (const char *in_fn, bool multiple)
 	  TerminateProcess (hProcess, 0);
 	  break;
 	case EXIT_PROCESS_DEBUG_EVENT:
+print_and_exit:
 	  print_dlls (&dll_list, isdll ? fn_win : NULL, process_fn);
 	  exitnow = true;
 	  break;



More information about the Cygwin-cvs mailing list