about summary refs log tree commit diff
path: root/ldso
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2016-11-01 02:49:09 +0100
committerRich Felker <dalias@aerifal.cx>2016-11-07 12:00:32 -0500
commit5ffe515ca485c8e6e57cd5acda6bc6008f85660c (patch)
tree99d377f4c22b97a642df989af8d1b6b3eb51ac3f /ldso
parent86e8cc0fd46f5789e80a16d68ae86f7358f64705 (diff)
downloadmusl-5ffe515ca485c8e6e57cd5acda6bc6008f85660c.tar.gz
musl-5ffe515ca485c8e6e57cd5acda6bc6008f85660c.tar.xz
musl-5ffe515ca485c8e6e57cd5acda6bc6008f85660c.zip
fix ldso reserved library name handling
If a DT_NEEDED entry was the prefix of a reserved library name
(up to the first dot) then it was incorrectly treated as a libc
reserved name.

e.g. libp.so dependency was not loaded as it matched libpthread
reserved name.
Diffstat (limited to 'ldso')
-rw-r--r--ldso/dynlink.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/ldso/dynlink.c b/ldso/dynlink.c
index d11776dc..acb73bc2 100644
--- a/ldso/dynlink.c
+++ b/ldso/dynlink.c
@@ -906,27 +906,27 @@ static struct dso *load_library(const char *name, struct dso *needed_by)
 	/* Catch and block attempts to reload the implementation itself */
 	if (name[0]=='l' && name[1]=='i' && name[2]=='b') {
 		static const char reserved[] =
-			"c\0pthread\0rt\0m\0dl\0util\0xnet\0";
-		const char *rp;
-		char *z = strchr(name, '.');
-		if (z) {
-			size_t l = z-name;
-			for (rp=reserved; *rp && strncmp(name+3, rp, l-3); rp+=strlen(rp)+1);
-			if (*rp) {
-				if (ldd_mode) {
-					/* Track which names have been resolved
-					 * and only report each one once. */
-					static unsigned reported;
-					unsigned mask = 1U<<(rp-reserved);
-					if (!(reported & mask)) {
-						reported |= mask;
-						dprintf(1, "\t%s => %s (%p)\n",
-							name, ldso.name,
-							ldso.base);
-					}
+			"c.pthread.rt.m.dl.util.xnet.";
+		const char *rp, *next;
+		for (rp=reserved; *rp; rp=next) {
+			next = strchr(rp, '.') + 1;
+			if (strncmp(name+3, rp, next-rp) == 0)
+				break;
+		}
+		if (*rp) {
+			if (ldd_mode) {
+				/* Track which names have been resolved
+				 * and only report each one once. */
+				static unsigned reported;
+				unsigned mask = 1U<<(rp-reserved);
+				if (!(reported & mask)) {
+					reported |= mask;
+					dprintf(1, "\t%s => %s (%p)\n",
+						name, ldso.name,
+						ldso.base);
 				}
-				is_self = 1;
 			}
+			is_self = 1;
 		}
 	}
 	if (!strcmp(name, ldso.name)) is_self = 1;