Re: ld.so fix for empty LD_PRELOAD

Previous thread: Re: Allegations regarding OpenBSD IPSEC by Theo de Raadt on Thursday, December 16, 2010 - 9:55 pm. (1 message)

Next thread: Vacante si proprietati by Consilier CFI on Friday, December 17, 2010 - 2:09 am. (1 message)
From: Stefan Sperling
Date: Thursday, December 16, 2010 - 2:43 pm

$ export LD_PRELOAD='' 
$ sed
sed: can't load library ''
$ env
env: can't load library ''
$ vim
/usr/local/bin/vim: can't load library ''
$ 

Is this the right way to fix it?

Index: loader.c
===================================================================
RCS file: /cvs/src/libexec/ld.so/loader.c,v
retrieving revision 1.120
diff -u -p -r1.120 loader.c
--- loader.c	25 Oct 2010 20:34:44 -0000	1.120
+++ loader.c	16 Dec 2010 21:40:07 -0000
@@ -493,7 +493,7 @@ _dl_boot(const char **argv, char **envp,
 	TAILQ_INSERT_TAIL(&_dlopened_child_list, n, next_sib);
 	exe_obj->opencount++;
 
-	if (_dl_preload != NULL)
+	if (_dl_preload != NULL && _dl_preload[0] != '\0')
 		_dl_dopreload(_dl_preload);
 
 	_dl_load_dep_libs(exe_obj, exe_obj->obj_flags, 1);

From: Mark Kettenis
Date: Friday, December 17, 2010 - 3:48 am

I'd say it works just fine without your fix.  If you really don't want

From: Marco Peereboom
Date: Friday, December 17, 2010 - 7:21 am

I kind of disagree with you mark and I think that the diff makes sense.


From: Mark Kettenis
Date: Friday, December 17, 2010 - 10:20 am

From: Han Boetes
Date: Friday, December 17, 2010 - 5:22 pm

If you want to check it check it properly. For example use stat to
see if LD_PRELOAD contains an existing file or use file to see if
it's really a library. But checking if LD_PRELOAD only contains an
empty string seems like a non check. Would you also check if it
contained a space or two spaces?

Actually there is no need to check since if the file is not a valid
library the result would be an error which the user has to debug.

Something about giving users enough rope...



# Han

From: Paul Irofti
Date: Saturday, December 18, 2010 - 10:18 am

I was just writting to ask what happens if there's a space or a tab :-)

I think Han phrased it quite well and I agree with him. There's no need
for this check.

And the fact that you encountered an empty LD_PRELOAD was so obviously a
case of bad scripting that when you wrote the second mail and confirmed
it I decided to reply and say no to this.

Previous thread: Re: Allegations regarding OpenBSD IPSEC by Theo de Raadt on Thursday, December 16, 2010 - 9:55 pm. (1 message)

Next thread: Vacante si proprietati by Consilier CFI on Friday, December 17, 2010 - 2:09 am. (1 message)