about summary refs log tree commit diff
path: root/Src/builtin.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2005-08-10 07:45:17 +0000
committerWayne Davison <wayned@users.sourceforge.net>2005-08-10 07:45:17 +0000
commitb97ff864af803eac1992b660a102f58953b0fe51 (patch)
treecfafbd7bd06ece46879a4ca33bc61698e02751b0 /Src/builtin.c
parentc73dd460190ca602114503d8dea3171165ff099e (diff)
downloadzsh-b97ff864af803eac1992b660a102f58953b0fe51.tar.gz
zsh-b97ff864af803eac1992b660a102f58953b0fe51.tar.xz
zsh-b97ff864af803eac1992b660a102f58953b0fe51.zip
Make printf %s handle an embedded null (21579).
Diffstat (limited to 'Src/builtin.c')
-rw-r--r--Src/builtin.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 811d02506..2df342533 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3745,21 +3745,24 @@ bin_print(char *name, char **args, Options ops, int func)
 	    d[1] = '\0';
 	    switch (*d = *c) {
 	    case 'c':
-		if (curarg) {
+		if (curarg)
 		    intval = *curarg;
-		} else
+		else
 		    intval = 0;
 		print_val(intval);
 		break;
 	    case 's':
-		stringval = curarg ? curarg : &nullstr;
-		print_val(stringval);
-		break;
 	    case 'b':
 		if (curarg) {
+		    char *b;
 		    int l;
-		    char *b = getkeystring(metafy(curarg, curlen, META_USEHEAP), &l,
-					   OPT_ISSET(ops,'b') ? 2 : 0, &nnl);
+		    if (*c == 'b') {
+			b = getkeystring(metafy(curarg, curlen, META_USEHEAP), &l,
+					 OPT_ISSET(ops,'b') ? 2 : 0, &nnl);
+		    } else {
+			b = curarg;
+			l = curlen;
+		    }
 		    /* handle width/precision here and use fwrite so that
 		     * nul characters can be output */
 		    if (prec >= 0 && prec < l) l = prec;