Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Avoid loading the main zsh binary as a module
- X-seq: zsh-workers 34387
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: PATCH: Avoid loading the main zsh binary as a module
- Date: Sun, 25 Jan 2015 19:21:39 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=SKafzv3ICJzCO8wC3+nLwlEaeUC62o2sNaa4lpALYiU=; b=HsPoIznQz7wuinV/CtXa+1lpp8695yaifP/NkzhXDL+x+3fr384OfCLlP4bYwWXvr2 UseGIWd0mkOWbnfHhrJ0py7Yy33gFihTkth7fP7qu16Nk0tawrBdVPUNS0NSyIB99oFF TLGiX/aR3UPl869SnUUNET6URF0BIxamV7USHRW+OSW40EjbNUPi/j110uSTqRStvOkD Sw5UakwenUfhFbTEZqGfJKoO/xUgOmwmiesbpPg/oQCGKy5UPZhpwC8t+jPG+FznQefs Cb5+QSO4KThFF4KFQ0vXuDCDJmD5Yu1tczRfARpJbhtgK0agyn4XHikjk3+Ecva8rGDO ndVw==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author