summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-09-18 09:42:44 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-09-18 09:42:44 +0000
commite4d3ee06b39043901054f1f20682a2e79c9f1924 (patch)
treedb3314a159e60b1fb564f40294833b5c2f47961c
parent2920c227d3f8e6d8af1f2b0c3163badb95cde9b5 (diff)
downloadzsh-e4d3ee06b39043901054f1f20682a2e79c9f1924.tar.gz
zsh-e4d3ee06b39043901054f1f20682a2e79c9f1924.tar.xz
zsh-e4d3ee06b39043901054f1f20682a2e79c9f1924.zip
25682: terminate history line before passing to zshaddhistory hook
-rw-r--r--ChangeLog5
-rw-r--r--Src/hist.c9
2 files changed, 12 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f4172a83e..a9240e419 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-09-18  Peter Stephenson  <pws@csr.com>
+
+	* 25682: Src/hist.c: terminate history line string before passing
+	down to zshaddhistory hook.
+
 2008-09-16  Peter Stephenson  <pws@csr.com>
 
 	* 25677: Doc/Zsh/prompt.yo, Src/exec.c, Src/init.c, Src/math.c,
diff --git a/Src/hist.c b/Src/hist.c
index f3979dfc0..55131f06e 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -1129,7 +1129,13 @@ hend(Eprog prog)
     if (hist_ignore_all_dups != isset(HISTIGNOREALLDUPS)
      && (hist_ignore_all_dups = isset(HISTIGNOREALLDUPS)) != 0)
 	histremovedups();
-    
+
+    /*
+     * Added the following in case the test "hptr < chline + 1"
+     * is more than just paranoia.
+     */
+    DPUTS(hptr < chline, "History end pointer off start of line");
+    *hptr = '\0';
     addlinknode(hookargs, "zshaddhistory");
     addlinknode(hookargs, chline);
     callhookfunc("zshaddhistory", hookargs, 1, &hookret);
@@ -1144,7 +1150,6 @@ hend(Eprog prog)
     if (hptr < chline + 1)
 	save = 0;
     else {
-	*hptr = '\0';
 	if (hptr[-1] == '\n') {
 	    if (chline[1]) {
 		*--hptr = '\0';