about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-06-25 17:49:16 -0400
committerRich Felker <dalias@aerifal.cx>2011-06-25 17:49:16 -0400
commit49388f3b7b72a1695bef05f64439b602b2e77a53 (patch)
tree918e3f7a6f97c8761bc46088ae2f7ee61ea67711 /src
parente8b8f3c90e02d8fa077be0f273fce1e48e2719d2 (diff)
downloadmusl-49388f3b7b72a1695bef05f64439b602b2e77a53.tar.gz
musl-49388f3b7b72a1695bef05f64439b602b2e77a53.tar.xz
musl-49388f3b7b72a1695bef05f64439b602b2e77a53.zip
handle library paths better (ignore empty path components, etc.)
Diffstat (limited to 'src')
-rw-r--r--src/ldso/dynlink.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index 56ba89eb..472e389d 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -208,15 +208,17 @@ static void *map_library(int fd, size_t *lenp, unsigned char **basep, size_t *dy
 static int path_open(const char *name, const char *search)
 {
 	char buf[2*NAME_MAX+2];
-	const char *s, *z;
+	const char *s=search, *z;
 	int l, fd;
-	for (s=search; *s; s+=l+!!z) {
+	for (;;) {
+		while (*s==':') s++;
+		if (!*s) return -1;
 		z = strchr(s, ':');
 		l = z ? z-s : strlen(s);
 		snprintf(buf, sizeof buf, "%.*s/%s", l, s, name);
 		if ((fd = open(buf, O_RDONLY))>=0) return fd;
+		s += l;
 	}
-	return -1;
 }
 
 static struct dso *load_library(const char *name)