From owner-freebsd-bugs@FreeBSD.ORG Sun May 18 14:10:01 2014 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 632CE987 for ; Sun, 18 May 2014 14:10:01 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3E45B2D12 for ; Sun, 18 May 2014 14:10:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s4IEA1hK003519 for ; Sun, 18 May 2014 14:10:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s4IEA1E4003518; Sun, 18 May 2014 14:10:01 GMT (envelope-from gnats) Resent-Date: Sun, 18 May 2014 14:10:01 GMT Resent-Message-Id: <201405181410.s4IEA1E4003518@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Wolfgang Jenkner Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 47402963 for ; Sun, 18 May 2014 14:05:45 +0000 (UTC) Received: from b2bfep11.mx.upcmail.net (b2bfep11.mx.upcmail.net [62.179.121.56]) by mx1.freebsd.org (Postfix) with ESMTP id A24202CFB for ; Sun, 18 May 2014 14:05:43 +0000 (UTC) Received: from edge11.upcmail.net ([192.168.13.81]) by b2bfep11-int.chello.at (InterMail vM.8.01.05.11 201-2260-151-128-20120928) with ESMTP id <20140518140535.ZKXA25882.b2bfep11-int.chello.at@edge11.upcmail.net> for ; Sun, 18 May 2014 16:05:35 +0200 Received: from iznogoud.viz ([91.119.56.164]) by edge11.upcmail.net with edge id 3S5b1o00P3YbPKv0BS5b8G; Sun, 18 May 2014 16:05:35 +0200 Received: from wolfgang by iznogoud.viz with local (Exim 4.82 (FreeBSD)) (envelope-from ) id 1Wm1iY-0004f5-Sr; Sun, 18 May 2014 16:05:34 +0200 Message-Id: <85mwefi3m9.fsf@iznogoud.viz> Date: Sat, 17 May 2014 15:33:40 +0200 From: Wolfgang Jenkner To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.114 Subject: bin/189911: [patch] LD_LIBMAP has no effect on rtld Cc: Konstantin Belousov X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 May 2014 14:10:01 -0000 >Number: 189911 >Category: bin >Synopsis: [patch] LD_LIBMAP has no effect on rtld >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun May 18 14:10:00 UTC 2014 >Closed-Date: >Last-Modified: >Originator: Wolfgang Jenkner >Release: FreeBSD 10.0-STABLE amd64 >Organization: >Environment: System: FreeBSD iznogoud.viz 10.0-STABLE FreeBSD 10.0-STABLE #0 r265095M: Tue Apr 29 20:38:44 CEST 2014 adm@iznogoud.viz:/usr/obj/usr/src/sys/IZNOGOUD-drm-update-38.a+ amd64 >Description: Mapping a shared library to another - existing or not existing - library via LD_LIBMAP, as described in rtld(1), has no effect (but it does work when done in libmap.conf). >How-To-Repeat: $ LD_LIBMAP=libncurses.so.8=libncurses.so.5 ldd /bin/ls /bin/ls: libutil.so.9 => /lib/libutil.so.9 (0x800823000) libncurses.so.8 => /lib/libncurses.so.8 (0x800a35000) libc.so.7 => /lib/libc.so.7 (0x800c82000) On the other hand, with $ cat /etc/libmap.conf [ls] libncurses.so.8 libncurses.so.5 $ we get $ ldd /bin/ls /bin/ls: libutil.so.9 => /lib/libutil.so.9 (0x800823000) libncurses.so.8 => /usr/local/lib/libncurses.so.5 (0x800a35000) libc.so.7 => /lib/libc.so.7 (0x800c53000) libtinfo.so.5.9 => /usr/local/lib/libtinfo.so.5.9 (0x800ffa000) $ if libncurses.so.5 from the devel/ncurses port exists. Otherwise, we get $ ldd /bin/ls /bin/ls: libutil.so.9 => /lib/libutil.so.9 (0x800823000) libncurses.so.8 => not found (0) libc.so.7 => /lib/libc.so.7 (0x800a35000) $ >Fix: The following patch is against 10-STABLE, but should apply to HEAD as well. It seems that, due to an oversight in HEAD r232862, lmc_parse() was passed wrong arguments in the libmap_override case. Index: libexec/rtld-elf/libmap.c =================================================================== --- libexec/rtld-elf/libmap.c (revision 265095) +++ libexec/rtld-elf/libmap.c (working copy) @@ -80,7 +80,7 @@ if (libmap_override) { /* - * Do some character replacement to make $LIBMAP look + * Do some character replacement to make $LD_LIBMAP look * like a text file, then parse it. */ libmap_override = xstrdup(libmap_override); @@ -94,8 +94,8 @@ break; } } - lmc_parse(p, strlen(p)); - free(p); + lmc_parse(libmap_override, p - libmap_override); + free(libmap_override); } return (lm_count == 0); >Release-Note: >Audit-Trail: >Unformatted: