diff options
-rw-r--r-- | debian/patches/cherry-pick-605a73e4-33429-disallow-non-integer-values-for-histsize-and-savehist-of-fc-p-and-fix-crash-on-zero-values-for-same.patch | 60 | ||||
-rw-r--r-- | debian/patches/series | 1 |
2 files changed, 61 insertions, 0 deletions
diff --git a/debian/patches/cherry-pick-605a73e4-33429-disallow-non-integer-values-for-histsize-and-savehist-of-fc-p-and-fix-crash-on-zero-values-for-same.patch b/debian/patches/cherry-pick-605a73e4-33429-disallow-non-integer-values-for-histsize-and-savehist-of-fc-p-and-fix-crash-on-zero-values-for-same.patch new file mode 100644 index 000000000..19b7a822d --- /dev/null +++ b/debian/patches/cherry-pick-605a73e4-33429-disallow-non-integer-values-for-histsize-and-savehist-of-fc-p-and-fix-crash-on-zero-values-for-same.patch @@ -0,0 +1,60 @@ +Origin: commit 605a73e415772a1d74cff39212618c8f1d58297b +Author: Barton E. Schaefer <schaefer@zsh.org> +Date: Fri Oct 10 23:12:57 2014 -0700 +Description: 33429: disallow non-integer values for HISTSIZE and SAVEHIST of "fc -p", and fix crash on zero values for same + +diff --git a/Src/builtin.c b/Src/builtin.c +index 4a10c7d..5b711ed 100644 +--- a/Src/builtin.c ++++ b/Src/builtin.c +@@ -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"); +diff --git a/Src/hist.c b/Src/hist.c +index 4660fd0..0831756 100644 +--- a/Src/hist.c ++++ b/Src/hist.c +@@ -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; diff --git a/debian/patches/series b/debian/patches/series index 8f45cdf1d..b66fd3099 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -3,3 +3,4 @@ cherry-pick-9982ab6f-missing-changelog-entry cherry-pick-0f73b35f-33391-vcs-info-git-fix-applied-patch-detection-on-git-am.patch cherry-pick-a03227de-33405-vcs-info-make-sure-maxexports-is-set-when-vcs-info-set-is-called.patch cherry-pick-22c4ea42-33403-be-conservative-about-redirecting-call-program-stderr-the-caller-may-have-already-done-so.patch +cherry-pick-605a73e4-33429-disallow-non-integer-values-for-histsize-and-savehist-of-fc-p-and-fix-crash-on-zero-values-for-same.patch |