* PATCH: Avoid loading the main zsh binary as a module
@ 2015-01-25 18:21 Mikael Magnusson
0 siblings, 0 replies; only message in thread
From: Mikael Magnusson @ 2015-01-25 18:21 UTC (permalink / raw)
To: zsh-workers
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-01-25 18:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-25 18:21 PATCH: Avoid loading the main zsh binary as a module Mikael Magnusson
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).