diff options
| author | Mikael Magnusson <mikachu@gmail.com> | 2026-05-13 00:59:29 +0200 |
|---|---|---|
| committer | Mikael Magnusson <mikachu@gmail.com> | 2026-05-16 18:28:32 +0200 |
| commit | 2c43edc5ce388c8efd40a0fc12b934e1c7f0bc99 (patch) | |
| tree | 70620def32d9a436427dc390425a61f83b86a85c | |
| parent | 54564: termcap, terminfo: reset u, fix metafy confusion (diff) | |
| download | zsh-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.
| -rw-r--r-- | ChangeLog | 3 | ||||
| -rw-r--r-- | Src/Modules/watch.c | 7 |
2 files changed, 7 insertions, 3 deletions
@@ -1,5 +1,8 @@ 2026-05-16 Mikael Magnusson <mikachu@gmail.com> + * 54565: Src/Modules/watch.c: watch: increase a quite tight + bound on format length + * 54564: Src/Modules/termcap.c, Src/Modules/terminfo.c: termcap, terminfo: reset u, fix metafy confusion 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); |
