From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: [PATCH] fix ldso reserved library name handling
Date: Tue, 1 Nov 2016 02:49:09 +0100 [thread overview]
Message-ID: <20161101014909.GF5749@port70.net> (raw)
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
next reply other threads:[~2016-11-01 1:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-01 1:49 Szabolcs Nagy [this message]
2016-11-07 17:03 ` Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161101014909.GF5749@port70.net \
--to=nsz@port70.net \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).