From f8164fb647a8e7947cfde137ddd9517b2fab51c4 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 18 Aug 2015 16:20:48 +0100 Subject: 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. --- Src/watch.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Src/watch.c') 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 '%': -- cgit 1.4.1