summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2005-10-19 21:59:34 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2005-10-19 21:59:34 +0000
commit2ddaeb605f4b7a89dab23a843ae79fbdc88afa69 (patch)
tree53bef461db285cdee0195eff2fe411cf6386d38a
parent26e60b1f3a375e22393b96640209ca26e63d87d4 (diff)
downloadzsh-2ddaeb605f4b7a89dab23a843ae79fbdc88afa69.tar.gz
zsh-2ddaeb605f4b7a89dab23a843ae79fbdc88afa69.tar.xz
zsh-2ddaeb605f4b7a89dab23a843ae79fbdc88afa69.zip
21890: fix segmentation error in left prompt truncation and a couple of minor
inconsistencies
-rw-r--r--ChangeLog5
-rw-r--r--Src/Zle/zle_utils.c3
-rw-r--r--Src/builtin.c8
-rw-r--r--Src/prompt.c2
4 files changed, 12 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 827123aae..0655968a4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2005-10-19  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
+	* 21890: Src/builtin.c, Src/prompt.c, Src/zle_utils.c: allocation
+	inconsistencies in print builtin, segmentation error with
+	left prompt truncation from 21882, warning about variable
+	signedness in zle_utils.c.
+
 	* 21887: Src/Zle/zle_refresh.c: attempt to display wide characters
 	wider than one screen cell properly.
 
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index cfc77de27..a65aa05d0 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -787,7 +787,8 @@ showmsg(char const *msg)
     ZLE_CHAR_T c;
 #ifdef ZLE_UNICODE_SUPPORT
     char *umsg;
-    int ulen, ret, width;
+    int ulen, ret;
+    size_t width;
     mbstate_t ps;
 #endif
 
diff --git a/Src/builtin.c b/Src/builtin.c
index cd1358614..063baa687 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3368,7 +3368,7 @@ bin_print(char *name, char **args, Options ops, int func)
 	     */
 	    char *str = unmetafy(promptexpand(metafy(args[n], len[n],
 						     META_NOALLOC), 0, NULL, NULL), &len[n]);
-	    args[n] = dupstring(str);
+	    args[n] = dupstrpfx(str, len[n]);
 	    free(str);
 	}
 	/* -D option -- interpret as a directory, and use ~ */
@@ -3378,9 +3378,9 @@ bin_print(char *name, char **args, Options ops, int func)
 	    queue_signals();
 	    d = finddir(args[n]);
 	    if(d) {
-		char *arg = zhalloc(strlen(args[n]) + 1);
-		sprintf(arg, "~%s%s", d->nam,
-			args[n] + strlen(d->dir));
+		int dirlen = strlen(d->dir);
+		char *arg = zhalloc(len[n] - dirlen + strlen(d->nam) + 2);
+		sprintf(arg, "~%s%s", d->nam, args[n] + dirlen);
 		args[n] = arg;
 		len[n] = strlen(args[n]);
 	    }
diff --git a/Src/prompt.c b/Src/prompt.c
index f96369760..8b3aa531e 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -1078,7 +1078,7 @@ prompttrunc(int arg, int truncchar, int doprint, int endchar)
 		    int remw;
 		    mbstate_t mbs;
 
-		    fulltextptr = fulltext = bp;
+		    fulltextptr = fulltext = ptr + ntrunc;
 		    memmove(fulltext, ptr, fullen);
 		    fulltext[fullen] = '\0';