[PATCH] Fix catchsegv

Jakub Jelinek jakub@redhat.com
Tue Oct 19 12:10:00 GMT 2004


Hi!

$LIB in LD_PRELOAD=.../$LIB/libSegFault.so needs to be escaped
from shell.  Either of the following patches work, I'd say adding
single quotes is better in case of weirdo slibdir paths e.g. with
embedded spaces and other chars (but that will not handle
properly paths with embedded quotes).

	Jakub
-------------- next part --------------
2004-10-19  Jakub Jelinek  <jakub@redhat.com>

	* debug/Makefile (catchsegv): Prefix $LIB with a backslash.

--- libc/debug/Makefile.jj	2004-10-19 13:45:37.000000000 +0200
+++ libc/debug/Makefile	2004-10-19 13:57:34.623059205 +0200
@@ -72,7 +72,7 @@ include ../Rules
 
 $(objpfx)catchsegv: catchsegv.sh $(common-objpfx)soversions.mk \
 		    $(common-objpfx)config.make
-	slibpfx=`echo $(slibdir)|sed 's/lib\(64\|\)$$/$$LIB/'`; \
+	slibpfx=`echo $(slibdir)|sed 's/lib\(64\|\)$$/\\\\\\\\$$LIB/'`; \
 	sed -e 's|@VERSION@|$(version)|' -e "s|@SLIB@|$$slibpfx|" $< > $@.new
 	chmod 555 $@.new
 	mv -f $@.new $@
-------------- next part --------------
2004-10-19  Jakub Jelinek  <jakub@redhat.com>

	* debug/catchsegv.sh: Surround @SLIB@ into single quotes.

--- libc/debug/catchsegv.sh.jj	2004-10-19 13:45:37.000000000 +0200
+++ libc/debug/catchsegv.sh	2004-10-19 14:02:02.468479350 +0200
@@ -54,7 +54,7 @@ segv_output=`mktemp ${TMPDIR:-/tmp}/segv
 
 # Redirect stderr to avoid termination message from shell.
 (exec 3>&2 2>/dev/null
-LD_PRELOAD=${LD_PRELOAD:+${LD_PRELOAD}:}@SLIB@/libSegFault.so \
+LD_PRELOAD=${LD_PRELOAD:+${LD_PRELOAD}:}'@SLIB@'/libSegFault.so \
 SEGFAULT_USE_ALTSTACK=1 \
 SEGFAULT_OUTPUT_NAME=$segv_output \
 "$prog" ${1+"$@"} 2>&3 3>&-)


More information about the Libc-hacker mailing list