[uClibc-cvs] uClibc/ldso/util ldd.c,1.31,1.32

Erik Andersen andersen at uclibc.org
Mon Jun 16 07:34:29 UTC 2003


Update of /var/cvs/uClibc/ldso/util
In directory winder:/tmp/cvs-serv27673

Modified Files:
	ldd.c 
Log Message:
Fix a segfault when used on a library w/o an INTERP program header.


Index: ldd.c
===================================================================
RCS file: /var/cvs/uClibc/ldso/util/ldd.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- ldd.c	15 Jun 2003 06:13:36 -0000	1.31
+++ ldd.c	16 Jun 2003 07:34:25 -0000	1.32
@@ -122,6 +122,7 @@
 char *interp = NULL;
 char *interp_dir = NULL;
 int byteswap;
+static int interpreter_already_found=0;
 
 inline uint32_t byteswap32_to_host(uint32_t value)
 {
@@ -352,7 +353,7 @@
 	}
 
 	/* We add libc.so.0 elsewhere */
-	if ((tmp=strrchr(interp, '/')) != NULL)
+	if (interpreter_already_found && (tmp=strrchr(interp, '/')) != NULL)
 	{
 		int len = strlen(interp_dir);
 		if (strcmp(s, interp+1+len)==0)
@@ -409,14 +410,12 @@
 	}
 }
     
-static int interpreter_already_found=0;
 static struct library * find_elf_interpreter(Elf32_Ehdr* ehdr)
 {
 	Elf32_Phdr *phdr;
 
 	if (interpreter_already_found==1)
 		return NULL;
-	interpreter_already_found=1;
 	phdr = elf_find_phdr_type(PT_INTERP, ehdr);
 	if (phdr) {
 		struct library *cur, *newlib=NULL;
@@ -467,6 +466,7 @@
 			cur->next = newlib;
 		}
 #endif
+		interpreter_already_found=1;
 		return newlib;
 	}
 	return NULL;



More information about the uClibc-cvs mailing list