From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: PATCH: Avoid loading the main zsh binary as a module
Date: Sun, 25 Jan 2015 19:21:39 +0100 [thread overview]
Message-ID: <1422210099-12982-1-git-send-email-mikachu@gmail.com> (raw)
Was fiddling around a bit due to the previous issue, and noticed that
module_path=($'\0'); zmodload flurg
succeeded. I looked at man dlopen and found that dlopen(NULL, ) returns a
handle to the main program binary which we probably don't want to do here.
---
Src/module.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Src/module.c b/Src/module.c
index e78bd82..ddd0d90 100644
--- a/Src/module.c
+++ b/Src/module.c
@@ -1576,7 +1576,9 @@ try_load_module(char const *name)
if (l + (**pp ? strlen(*pp) : 1) > PATH_MAX)
continue;
sprintf(buf, "%s/%s.%s", **pp ? *pp : ".", name, DL_EXT);
- ret = dlopen(unmeta(buf), RTLD_LAZY | RTLD_GLOBAL);
+ unmetafy(buf, NULL);
+ if (*buf) /* dlopen(NULL) returns a handle to the main binary */
+ ret = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL);
}
return ret;
--
2.2.0.GIT
reply other threads:[~2015-01-25 18:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1422210099-12982-1-git-send-email-mikachu@gmail.com \
--to=mikachu@gmail.com \
--cc=zsh-workers@zsh.org \
/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/zsh/
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).