Re: LD_PRELOAD broken?

From: Kostik Belousov <kostikbel_at_gmail.com>
Date: Sat, 28 Mar 2009 15:47:40 +0200
On Sat, Mar 28, 2009 at 11:25:52AM +0100, Ed Schouten wrote:
> Hi all,
> 
> Is it possible that the changes to rtld-elf the last couple of weeks
> cause LD_PRELOAD to crash applications on startup? Very simple way to
> reproduce:
> 
> 	LD_PRELOAD=/lib/libc.so.7 ls
> 
> This causes a segmentation fault on startup, at least on AMD64.

Yes. The following fixes the case for me.

diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index 823427a..d98ade7 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
_at__at_ -1125,7 +1125,7 _at__at_ find_library(const char *xname, const Obj_Entry *refobj)
 	      xname);
 	    return NULL;
 	}
-	if (refobj->z_origin)
+	if (refobj != NULL && refobj->z_origin)
 	    return origin_subst(xname, refobj->origin_path);
 	else
 	    return xstrdup(xname);

Received on Sat Mar 28 2009 - 12:47:46 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:45 UTC