From owner-freebsd-audit Tue May 14 15:25:43 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mail.musha.org (daemon.musha.org [218.44.187.2]) by hub.freebsd.org (Postfix) with ESMTP id 00FBD37B401 for ; Tue, 14 May 2002 15:25:36 -0700 (PDT) Received: from archon.local.idaemons.org (archon.local.idaemons.org [192.168.1.32]) by mail.musha.org (Postfix) with ESMTP id BCE8D4D801 for ; Wed, 15 May 2002 07:25:34 +0900 (JST) Date: Wed, 15 May 2002 07:25:35 +0900 Message-ID: <86adr2z7s0.wl@archon.local.idaemons.org> From: "Akinori MUSHA" To: audit@FreeBSD.org Subject: a tiny bug in ldd(1)'s shlib support User-Agent: Wanderlust/2.9.11 (Unchained Melody) SEMI/1.14.3 (Ushinoya) LIMIT/1.14.7 (Fujiidera) APEL/10.3 MULE XEmacs/21.1 (patch 14) (Cuyahoga Valley) (i386--freebsd) Organization: Associated I. Daemons X-PGP-Public-Key: finger knu@FreeBSD.org X-PGP-Fingerprint: 081D 099C 1705 861D 4B70 B04A 920B EFC7 9FD9 E1EE MIME-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I found a tiny bug in ldd(1)'s shlib support. If you do ldd against libc.so, you'll get the following: knu@archon[2]% ldd /usr/lib/libc.so /usr/lib/libc.so: ldd: /usr/lib/libc.so: (null) /usr/lib/libc.so: exit status 1 This is because dlopen("/usr/lib/libc.so", RTLD_TRACE) returns without an error as ldd(1) has already libc.so loaded. The attached patch fixes the proglem by checking the return value of dlopen() and exiting gracefully when no error has occurred: knu@archon[2]% ./ldd /usr/lib/libc.so /usr/lib/libc.so: Can I commit this? (Or someone else please) -- / /__ __ Akinori.org / MUSHA.org / ) ) ) ) / FreeBSD.org / Ruby-lang.org Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp "Somewhere out of a memory.. of lighted streets on quiet nights.." Index: ldd.c =================================================================== RCS file: /home/ncvs/src/usr.bin/ldd/ldd.c,v retrieving revision 1.31 diff -u -r1.31 ldd.c --- ldd.c 28 Apr 2002 12:55:35 -0000 1.31 +++ ldd.c 14 May 2002 22:09:58 -0000 @@ -220,12 +220,13 @@ } break; case 0: - if (is_shlib == 0) { + if (is_shlib) { + if (dlopen(*argv, RTLD_TRACE)) + _exit(0); /* libc.so */ + warnx("%s: %s", *argv, dlerror()); + } else { execl(*argv, *argv, (char *)NULL); warn("%s", *argv); - } else { - dlopen(*argv, RTLD_TRACE); - warnx("%s: %s", *argv, dlerror()); } _exit(1); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message