From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22487 invoked by alias); 11 Jul 2007 11:33:21 -0000 Received: (qmail 22471 invoked by uid 22791); 11 Jul 2007 11:33:21 -0000 X-Spam-Check-By: sourceware.org Received: from sunsite.ms.mff.cuni.cz (HELO sunsite.mff.cuni.cz) (195.113.15.26) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 11 Jul 2007 11:33:16 +0000 Received: from sunsite.mff.cuni.cz (localhost.localdomain [127.0.0.1]) by sunsite.mff.cuni.cz (8.13.8/8.13.8) with ESMTP id l6BBaAPs026013; Wed, 11 Jul 2007 13:36:10 +0200 Received: (from jakub@localhost) by sunsite.mff.cuni.cz (8.13.8/8.13.8/Submit) id l6BBaATA026005; Wed, 11 Jul 2007 13:36:10 +0200 Date: Wed, 11 Jul 2007 11:33:00 -0000 From: Jakub Jelinek To: Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] Fix RTLD_DI_SERINFO{,SIZE} (BZ #4776) Message-ID: <20070711113609.GL4603@sunsite.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2007-07/txt/msg00011.txt.bz2 Hi! Current directory (from empty library search path elements in LD_LIBRARY_PATH, DT_R{UN,}PATH) has r->dirnamelen == 0 and thus mempcpy , r->dirnamelen - 1) crashes on it. While fixing this I have noticed that searchpath elements / (the only ones that can have dirnamelen == 1) result in "" strings, which is confusing too. 2007-07-11 Jakub Jelinek [BZ #4776] * elf/dl-load.c (_dl_rtld_di_serinfo): Output / in LD_LIBRARY_PATH, RPATH etc. as "/" rather than "", don't segfault on empty paths, instead output ".". * dlfcn/Makefile (distribute): Add glreflib3.c. (module-names): Add glreflib3. ($(objpfx)tst-dlinfo.out): Depend on glreflib3.so rather than glreflib1.so. (LDFLAGS_glreflib3.so): New. * dlfcn/tst-dlinfo.c (do_test): Load glreflib3.so instead of glreflib1.so. * dlfcn/glreflib3.c: New file. --- libc/elf/dl-load.c.jj 2007-07-03 12:36:59.000000000 +0200 +++ libc/elf/dl-load.c 2007-07-11 13:21:18.000000000 +0200 @@ -2273,14 +2273,17 @@ _dl_rtld_di_serinfo (struct link_map *lo if (counting) { si->dls_cnt++; - si->dls_size += r->dirnamelen; + si->dls_size += r->dirnamelen < 2 ? r->dirnamelen : 2; } else { Dl_serpath *const sp = &si->dls_serpath[idx++]; sp->dls_name = allocptr; - allocptr = __mempcpy (allocptr, - r->dirname, r->dirnamelen - 1); + if (r->dirnamelen < 2) + *allocptr++ = r->dirnamelen ? '/' : '.'; + else + allocptr = __mempcpy (allocptr, + r->dirname, r->dirnamelen - 1); *allocptr++ = '\0'; sp->dls_flags = flags; } --- libc/dlfcn/Makefile.jj 2006-10-31 23:05:28.000000000 +0100 +++ libc/dlfcn/Makefile 2007-07-11 13:12:07.000000000 +0200 @@ -23,7 +23,8 @@ libdl-routines := dlopen dlclose dlsym d dlmopen dlfcn routines := $(patsubst %,s%,$(filter-out dlfcn,$(libdl-routines))) elide-routines.os := $(routines) -distribute := dlopenold.c glreflib1.c glreflib2.c failtestmod.c \ +distribute := dlopenold.c glreflib1.c glreflib2.c glreflib3.c \ + failtestmod.c \ defaultmod1.c defaultmod2.c errmsg1mod.c modatexit.c \ modcxaatexit.c modstatic.c modstatic2.c \ bug-dlsym1-lib1.c bug-dlsym1-lib2.c bug-atexit1-lib.c \ @@ -43,8 +44,8 @@ tests = glrefmain failtest tst-dladdr de bug-dlopen1 bug-dlsym1 tst-dlinfo bug-atexit1 bug-atexit2 \ bug-atexit3 tstatexit endif -modules-names = glreflib1 glreflib2 failtestmod defaultmod1 defaultmod2 \ - errmsg1mod modatexit modcxaatexit \ +modules-names = glreflib1 glreflib2 glreflib3 failtestmod defaultmod1 \ + defaultmod2 errmsg1mod modatexit modcxaatexit \ bug-dlsym1-lib1 bug-dlsym1-lib2 bug-atexit1-lib \ bug-atexit2-lib bug-atexit3-lib @@ -83,7 +84,8 @@ $(objpfx)tst-dladdr: $(libdl) $(objpfx)tst-dladdr.out: $(objpfx)glreflib1.so $(objpfx)tst-dlinfo: $(libdl) -$(objpfx)tst-dlinfo.out: $(objpfx)glreflib1.so +$(objpfx)tst-dlinfo.out: $(objpfx)glreflib3.so +LDFLAGS-glreflib3.so = -Wl,-rpath,: LDFLAGS-default = $(LDFLAGS-rdynamic) $(objpfx)default: $(libdl) $(objpfx)defaultmod1.so $(objpfx)defaultmod2.so --- libc/dlfcn/tst-dlinfo.c.jj 2003-03-16 00:14:48.000000000 +0100 +++ libc/dlfcn/tst-dlinfo.c 2007-07-11 13:13:41.000000000 +0200 @@ -29,7 +29,7 @@ do_test (void) { int status = 0; - void *handle = dlopen ("glreflib1.so", RTLD_NOW); + void *handle = dlopen ("glreflib3.so", RTLD_NOW); if (handle == NULL) error (EXIT_FAILURE, 0, "cannot load: glreflib1.so: %s", dlerror ()); --- libc/dlfcn/glreflib3.c.jj 2007-07-11 13:10:12.000000000 +0200 +++ libc/dlfcn/glreflib3.c 2007-07-11 13:10:06.000000000 +0200 @@ -0,0 +1 @@ +#include "glreflib1.c" Jakub