summaryrefslogtreecommitdiffstats
path: root/Src/Modules
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2026-05-13 00:59:29 +0200
committerMikael Magnusson <mikachu@gmail.com>2026-05-16 18:28:32 +0200
commit2c43edc5ce388c8efd40a0fc12b934e1c7f0bc99 (patch)
tree70620def32d9a436427dc390425a61f83b86a85c /Src/Modules
parent54564: termcap, terminfo: reset u, fix metafy confusion (diff)
downloadzsh-2c43edc5ce388c8efd40a0fc12b934e1c7f0bc99.tar
zsh-2c43edc5ce388c8efd40a0fc12b934e1c7f0bc99.tar.gz
zsh-2c43edc5ce388c8efd40a0fc12b934e1c7f0bc99.tar.bz2
zsh-2c43edc5ce388c8efd40a0fc12b934e1c7f0bc99.tar.lz
zsh-2c43edc5ce388c8efd40a0fc12b934e1c7f0bc99.tar.xz
zsh-2c43edc5ce388c8efd40a0fc12b934e1c7f0bc99.tar.zst
zsh-2c43edc5ce388c8efd40a0fc12b934e1c7f0bc99.zip
54565: watch: increase a quite tight bound on format length
And also make sure metafy won't write outside the buffer, it can in theory become twice as long, so use half the buffer size at most.
Diffstat (limited to 'Src/Modules')
-rw-r--r--Src/Modules/watch.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Src/Modules/watch.c b/Src/Modules/watch.c
index f23819b25..c4571c7e7 100644
--- a/Src/Modules/watch.c
+++ b/Src/Modules/watch.c
@@ -241,7 +241,7 @@ watch3ary(int inout, WATCH_STRUCT_UTMP *u, char *fmt, int prnt)
static char *
watchlog2(int inout, WATCH_STRUCT_UTMP *u, char *fmt, int prnt, int fini)
{
- char buf[40], buf2[80];
+ char buf[256], buf2[80];
time_t timet;
struct tm *tm;
char *fm2;
@@ -332,7 +332,7 @@ watchlog2(int inout, WATCH_STRUCT_UTMP *u, char *fmt, int prnt, int fini)
case 'D':
if (fm2[1] == '{') {
char *dd, *ss;
- int n = 79;
+ int n = sizeof(buf2)-1;
for (ss = fm2 + 2, dd = buf2;
n-- && *ss && *ss != '}'; ++ss, ++dd)
@@ -349,7 +349,8 @@ watchlog2(int inout, WATCH_STRUCT_UTMP *u, char *fmt, int prnt, int fini)
}
timet = getlogtime(u, inout);
tm = localtime(&timet);
- len = ztrftime(buf, 40, fm2, tm, 0L);
+ /* metafy may double the length in the worst case */
+ len = ztrftime(buf, sizeof(buf)/2, fm2, tm, 0L);
if (len > 0)
metafy(buf, len, META_NOALLOC);
applytextattributes(TSC_RAW);