From 005ba515dcf15a6e10fdda6af130c317f8b4e4b7 Mon Sep 17 00:00:00 2001 From: Akinori MUSHA Date: Fri, 17 May 2002 17:06:56 +0000 Subject: [PATCH] Fix a tiny bug in shlib support of ldd(1); if dlopen(lib, RTLD_TRACE) returns, exit gracefully with 0. This fixes the behavior you see when you specify libc.so. It occurs because ldd(1) itself is linked with libc.so. $ ldd /usr/lib/libc.so /usr/lib/libc.so: ldd: /usr/lib/libc.so: (null) /usr/lib/libc.so: exit status 1 Reviewed by: silence of audit@ --- usr.bin/ldd/ldd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/usr.bin/ldd/ldd.c b/usr.bin/ldd/ldd.c index 8e5e5d2f2bcf..68f99887d298 100644 --- a/usr.bin/ldd/ldd.c +++ b/usr.bin/ldd/ldd.c @@ -220,12 +220,13 @@ main(int argc, char *argv[]) } 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); }