From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9832 invoked by alias); 25 Jan 2015 18:27:43 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34387 Received: (qmail 20538 invoked from network); 25 Jan 2015 18:27:41 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 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== X-Received: by 10.194.62.235 with SMTP id b11mr4393239wjs.73.1422210104601; Sun, 25 Jan 2015 10:21:44 -0800 (PST) From: Mikael Magnusson 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 Message-Id: <1422210099-12982-1-git-send-email-mikachu@gmail.com> X-Mailer: git-send-email 2.2.0.GIT 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