1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-19 11:31:26 +01:00

33429: disallow non-integer values for HISTSIZE and SAVEHIST of "fc -p", and fix crash on zero values for same

This commit is contained in:
Barton E. Schaefer 2014-10-10 23:12:57 -07:00
parent 22c4ea424c
commit 605a73e415
3 changed files with 25 additions and 7 deletions

View file

@ -1,3 +1,9 @@
2014-10-10 Barton E. Schaefer <schaefer@zsh.org>
* 33429: Src/builtin.c, Src/hist.c: disallow non-integer values
for the temporary HISTSIZE and SAVEHIST of "fc -p", and fix
crash on zero values for same
2014-10-09 Frank Terbeck <ft@bewatermyfriend.org>
* 33405: Functions/VCS_Info/vcs_info: Make sure maxexports

View file

@ -1363,10 +1363,19 @@ bin_fc(char *nam, char **argv, Options ops, int func)
if (*argv) {
hf = *argv++;
if (*argv) {
hs = zstrtol(*argv++, NULL, 10);
if (*argv)
shs = zstrtol(*argv++, NULL, 10);
else
char *check;
hs = zstrtol(*argv++, &check, 10);
if (*check) {
zwarnnam("fc", "HISTSIZE must be an integer");
return 1;
}
if (*argv) {
shs = zstrtol(*argv++, &check, 10);
if (*check) {
zwarnnam("fc", "SAVEHIST must be an integer");
return 1;
}
} else
shs = hs;
if (*argv) {
zwarnnam("fc", "too many arguments");

View file

@ -1110,8 +1110,11 @@ static void
putoldhistentryontop(short keep_going)
{
static Histent next = NULL;
Histent he = keep_going? next : hist_ring->down;
next = he->down;
Histent he = (keep_going || !hist_ring) ? next : hist_ring->down;
if (he)
next = he->down;
else
return;
if (isset(HISTEXPIREDUPSFIRST) && !(he->node.flags & HIST_DUP)) {
static zlong max_unique_ct = 0;
if (!keep_going)
@ -1151,7 +1154,7 @@ prepnexthistent(void)
freehistnode(&hist_ring->node);
}
if (histlinect < histsiz) {
if (histlinect < histsiz || !hist_ring) {
he = (Histent)zshcalloc(sizeof *he);
if (!hist_ring)
hist_ring = he->up = he->down = he;