From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10690 Path: news.gmane.org!.POSTED!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] fix ldso reserved library name handling Date: Tue, 1 Nov 2016 02:49:09 +0100 Message-ID: <20161101014909.GF5749@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1477964974 30432 195.159.176.226 (1 Nov 2016 01:49:34 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 1 Nov 2016 01:49:34 +0000 (UTC) User-Agent: Mutt/1.6.0 (2016-04-01) To: musl@lists.openwall.com Original-X-From: musl-return-10703-gllmg-musl=m.gmane.org@lists.openwall.com Tue Nov 01 02:49:28 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1c1OCY-0006c3-P5 for gllmg-musl@m.gmane.org; Tue, 01 Nov 2016 02:49:22 +0100 Original-Received: (qmail 5845 invoked by uid 550); 1 Nov 2016 01:49:24 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 5805 invoked from network); 1 Nov 2016 01:49:21 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline Xref: news.gmane.org gmane.linux.lib.musl.general:10690 Archived-At: 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. --- this is not the smallest possible patch (most of the diff is indentation change), but i found the code cleaner without the z and l-3 computation. ldso/dynlink.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/ldso/dynlink.c b/ldso/dynlink.c index d11776d..acb73bc 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; -- 2.10.1