Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Segfault copying an emulated function outside of emulation
- X-seq: zsh-workers 50359
- From: Matthew Martin <phy1729@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Segfault copying an emulated function outside of emulation
- Date: Thu, 9 Jun 2022 12:29:13 -0500
- Archived-at: <https://zsh.org/workers/50359>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: zsh-workers@xxxxxxx
ahmubashshir on IRC reported the following causes zsh to segfault
zsh -c 'emulate sh -c "foo(){ :; }"; functions -c foo bar'
This seems to be because bin_functions calls sticky_emulation_dup with
sticky which is NULL outside of emulation. The below patch fixes the
segfault, but I can't claim to be terribly familiar with the code.
diff --git a/Src/builtin.c b/Src/builtin.c
index 1cef7cce8..4a220ccd7 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3304,7 +3304,7 @@ bin_functions(char *name, char **argv, Options ops, int func)
if (newsh->redir)
newsh->redir->nref++;
if (shf->sticky)
- newsh->sticky = sticky_emulation_dup(sticky, 0);
+ newsh->sticky = sticky_emulation_dup(shf->sticky, 0);
shfunctab->addnode(shfunctab, ztrdup(argv[1]), &newsh->node);
return 0;
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author