From 6a44e26b674d67ec8e326bd1f85e9cdb9fbd59c2 Mon Sep 17 00:00:00 2001
From: Eric Andersen <andersen@codepoet.org>
Date: Fri, 24 May 2002 14:30:15 +0000
Subject: Fix a couple of silly bugs I'd left in while fixing things  -Erik

---
 ldso/util/ldd.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

(limited to 'ldso/util')

diff --git a/ldso/util/ldd.c b/ldso/util/ldd.c
index 18efc50bd..6b9326b53 100644
--- a/ldso/util/ldd.c
+++ b/ldso/util/ldd.c
@@ -244,10 +244,12 @@ void locate_library_file(Elf32_Ehdr* ehdr, Elf32_Dyn* dynamic, char *strtab,
 	/* Next look for libraries wherever the shared library 
 	 * loader was installed -- this is usually where we
 	 * should find things... */
-	search_for_named_library(lib->name, buf, interp_dir);
-	if (*buf != '\0') {
-		lib->path = buf;
-		return;
+	if (interp_dir) {
+		search_for_named_library(lib->name, buf, interp_dir);
+		if (*buf != '\0') {
+			lib->path = buf;
+			return;
+		}
 	}
 
 	/* Lastly, search the standard list of paths for the library.
@@ -355,6 +357,10 @@ static void find_elf_interpreter(Elf32_Ehdr* ehdr, Elf32_Dyn* dynamic, char *str
 		tmp = strrchr(interp_dir, '/');
 		if (*tmp)
 			*tmp = '\0';
+		else {
+			free(interp_dir);
+			interp_dir = interp;
+		}
 		tmp1 = tmp = s;
 		while (*tmp) {
 			if (*tmp == '/')
@@ -495,7 +501,7 @@ int main( int argc, char** argv)
 		got_em_all=1;
 		printf("\t%s => %s\n", cur->name, cur->path);
 	}
-	if (got_em_all==1)
+	if (interp_dir && got_em_all==1)
 		printf("\t%s => %s\n", interp, interp);
 	if (got_em_all==0)
 		printf("\tnot a dynamic executable\n");
-- 
cgit v1.2.3