about summary refs log tree commit diff
path: root/Src/builtin.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2015-08-18 16:20:48 +0100
committerPeter Stephenson <pws@zsh.org>2015-08-18 16:20:48 +0100
commitf8164fb647a8e7947cfde137ddd9517b2fab51c4 (patch)
tree493d0eaddda9ee2e14772282db0a70aa07903cf3 /Src/builtin.c
parent5292d60eb1b2ed5e021e3ee3d05bf08136757ac4 (diff)
downloadzsh-f8164fb647a8e7947cfde137ddd9517b2fab51c4.tar.gz
zsh-f8164fb647a8e7947cfde137ddd9517b2fab51c4.tar.xz
zsh-f8164fb647a8e7947cfde137ddd9517b2fab51c4.zip
36227: attempt to fix metafication problem with ztrftime.
fmt is treated as metafied on entry; use returned length to ensure
we metafy or output the correct length if there are embedded nulls.
Diffstat (limited to 'Src/builtin.c')
-rw-r--r--Src/builtin.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 4a97a3163..572a0dd68 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -1783,9 +1783,12 @@ fclist(FILE *f, Options ops, zlong first, zlong last,
 	       command, if required */
 	    if (tdfmt != NULL) {
 		struct tm *ltm;
+		int len;
 		ltm = localtime(&ent->stim);
-		if (ztrftime(timebuf, 256, tdfmt, ltm, 0L))
-		    fprintf(f, "%s  ", timebuf);
+		if ((len = ztrftime(timebuf, 256, tdfmt, ltm, 0L)) >= 0) {
+		    fwrite(timebuf, 1, len, f);
+		    fprintf(f, "  ");
+		}
 	    }
 	    /* display the time taken by the command, if required */
 	    if (OPT_ISSET(ops,'D')) {