diff options
author | Peter Stephenson <pws@zsh.org> | 2015-08-18 16:20:48 +0100 |
---|---|---|
committer | Peter Stephenson <pws@zsh.org> | 2015-08-18 16:20:48 +0100 |
commit | f8164fb647a8e7947cfde137ddd9517b2fab51c4 (patch) | |
tree | 493d0eaddda9ee2e14772282db0a70aa07903cf3 /Src/Modules/stat.c | |
parent | 5292d60eb1b2ed5e021e3ee3d05bf08136757ac4 (diff) | |
download | zsh-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/Modules/stat.c')
-rw-r--r-- | Src/Modules/stat.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Src/Modules/stat.c b/Src/Modules/stat.c index 6fc53894c..396177149 100644 --- a/Src/Modules/stat.c +++ b/Src/Modules/stat.c @@ -197,8 +197,11 @@ stattimeprint(time_t tim, char *outbuf, int flags) } if (flags & STF_STRING) { char *oend = outbuf + strlen(outbuf); - ztrftime(oend, 40, timefmt, (flags & STF_GMT) ? gmtime(&tim) : - localtime(&tim), 0L); + /* Where the heck does "40" come from? */ + int len = ztrftime(oend, 40, timefmt, (flags & STF_GMT) ? gmtime(&tim) : + localtime(&tim), 0L); + if (len > 0) + metafy(oend, len, META_NOALLOC); if (flags & STF_RAW) strcat(oend, ")"); } |