about summary refs log tree commit diff
path: root/Src/watch.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/watch.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/watch.c')
-rw-r--r--Src/watch.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Src/watch.c b/Src/watch.c
index e1bdaa4a0..c804913ad 100644
--- a/Src/watch.c
+++ b/Src/watch.c
@@ -237,6 +237,7 @@ watchlog2(int inout, WATCH_STRUCT_UTMP *u, char *fmt, int prnt, int fini)
     time_t timet;
     struct tm *tm;
     char *fm2;
+    int len;
 # ifdef WATCH_UTMP_UT_HOST
     char *p;
     int i;
@@ -330,7 +331,9 @@ watchlog2(int inout, WATCH_STRUCT_UTMP *u, char *fmt, int prnt, int fini)
 		    }
 		    timet = getlogtime(u, inout);
 		    tm = localtime(&timet);
-		    ztrftime(buf, 40, fm2, tm, 0L);
+		    len = ztrftime(buf, 40, fm2, tm, 0L);
+		    if (len > 0)
+			metafy(buf, len, META_NOALLOC);
 		    printf("%s", (*buf == ' ') ? buf + 1 : buf);
 		    break;
 		case '%':