25338: disallow usage of current history line in fc

This commit is contained in:
Peter Stephenson 2008-07-25 08:55:26 +00:00
parent 8d17ae7628
commit 897e8085ba
2 changed files with 20 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2008-07-25 Peter Stephenson <pws@csr.com>
* 25338: Src/builtin.c: disallow fc editing of the current
history line which has bad effects on stack usage and temporary
files.
2008-07-23 Clint Adams <clint@zsh.org>
* 25330: Doc/Zsh/mod_curses.yo: fix description of

View File

@ -1446,6 +1446,20 @@ bin_fc(char *nam, char **argv, Options ops, int func)
unqueue_signals();
zwarnnam("fc", "can't open temp file: %e", errno);
} else {
/*
* Nasty behaviour results if we use the current history
* line here. Treat it as if it doesn't exist, unless
* that gives us an empty range.
*/
if (last >= curhist) {
last = curhist - 1;
if (first > last) {
unqueue_signals();
zwarnnam("fc", "invalid use of current history line");
unlink(fil);
return 1;
}
}
ops->ind['n'] = 1; /* No line numbers here. */
if (!fclist(out, ops, first, last, asgf, pprog)) {
char *editor;