delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/2001/03/25/15:29:29

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-developers-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-developers-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin-developers AT sources DOT redhat DOT com
Message-ID: <3ABE54D9.DF4E4EA0@gmx.de>
Date: Sun, 25 Mar 2001 22:28:09 +0200
From: Reinhard Nissl <rnissl AT gmx DOT de>
X-Mailer: Mozilla 4.76 [en] (Windows NT 5.0; U)
X-Accept-Language: de,en,fr
MIME-Version: 1.0
To: "cygwin-developers AT cygwin DOT com" <cygwin-developers AT cygwin DOT com>
Subject: dlopen() & get_full_path_of_dll()

This is a multi-part message in MIME format.
--------------A5B9839B56B6014458738549
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

First, is there a certain reason, why get_full_path_of_dll() doesn't lookup up
the application directory?

The comment above the function tells me, that it should behave like
LoadLibrary() and this function searches the application directory in the
first place.

If this feature doesn't break with any cygwin philosophy, please apply the
attached patch.

Second, if get_full_path_of_dll() returns NULL, then the variable fullpath in
dlopen() is NULL too. This variable is then passed to LoadLibrary(), which
causes a crash.

The attached patch addresses this issue too, by adding a simple if-statement
around LoadLibrary().

BTW: the patch is against cygwin-1.1.8-2. I know, that this is not 100% what
you expect for suppling a patch, but I was too lazy to look for more recent
source package.

Motivation:
I triggered this bug, while playing with cdrtools-1.10a17. cdrecord want's to
load wnaspi32.dll and has crashed, when the library was not available on the
system, or when the library was not in one of the directories, that were
searched by get_full_path_of_dll().

As I share cdrtools with other people on our local network, I'd like to put
wnaspi32.dll into the directory, where cdrecord.exe resides. After my patch,
cdrecord can be used easily without the need to configure anyones system in a
certain way (setup environment variables, copy libraries, change current
directory, etc.).

Bye.
--
Dipl.-Inform. (FH) Reinhard Nissl
mailto:rnissl AT gmx DOT de
--------------A5B9839B56B6014458738549
Content-Type: text/plain; charset=us-ascii;
 name="dlfcn.cc.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="dlfcn.cc.patch"

--- dlfcn.cc.orig	Tue Oct 10 01:00:50 2000
+++ dlfcn.cc	Sun Mar 25 21:56:30 2001
@@ -102,6 +102,24 @@
   if (isabspath (str))
     ret = name;
 
+  /* application directory */
+  if (!ret)
+    {
+      if (GetModuleFileName (NULL, buf, MAX_PATH) == 0)
+	small_printf ("WARNING: get_full_path_of_dll can't get module file name win32 %E\n");
+      else
+	{
+	  char *p = strrchr (buf, '\\');
+	  if (!p)
+	    small_printf ("WARNING: get_full_path_of_dll can't extract module path name\n");
+	  else
+	    {
+	      *p = '\0';
+	      ret = check_access (buf, name);
+	    }
+	}
+    }
+
   /* current directory */
   if (!ret)
     {
@@ -177,7 +195,8 @@
     {
       /* handle for the named library */
       const char *fullpath = get_full_path_of_dll (name);
-      ret = (void *) LoadLibrary (fullpath);
+      if (fullpath)
+	ret = (void *) LoadLibrary (fullpath);
     }
 
   if (!ret)

--------------A5B9839B56B6014458738549--


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019