a tiny bug in ldd(1)'s shlib support
"Akinori MUSHA" <[email protected]>
| Newsgroups | gmane.os.freebsd.devel.audit |
|---|---|
| Organization | Associated I. Daemons |
| Message-ID | <[email protected]> |
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 [email protected]
with "unsubscribe freebsd-audit" in the body of the message