diff options
author | Mikael Magnusson <mikachu@gmail.com> | 2024-02-04 16:44:21 +0100 |
---|---|---|
committer | Mikael Magnusson <mikachu@gmail.com> | 2024-02-04 16:48:44 +0100 |
commit | 653be0823da9a6b085a0092ac3a7b8792afc142a (patch) | |
tree | c58e4bf2e171e71c2f1c9a82ae67c48cf7fbfa40 | |
parent | ec446a6f349c3f0a31ccd4cd21a257555bf53382 (diff) | |
download | zsh-653be0823da9a6b085a0092ac3a7b8792afc142a.tar.gz zsh-653be0823da9a6b085a0092ac3a7b8792afc142a.tar.xz zsh-653be0823da9a6b085a0092ac3a7b8792afc142a.zip |
52517: ensure that %H is followed by {
The previous code would accept any character after %H assuming it was a {, which was probably also a buffer overrun sometimes.
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | Src/prompt.c | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog index 1804037f3..bb619cf49 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * 52516: Src/prompt.c: fix crash in %H when hlgroups is empty + * 52517: Src/prompt.c: ensure that %H is followed by { + 2024-02-03 Bart Schaefer <schaefer@zsh.org> * unposted: Util/printdefines: updates and fix omissions diff --git a/Src/prompt.c b/Src/prompt.c index b1e5041bd..0d674ceab 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -605,10 +605,12 @@ putpromptchar(int doprint, int endchar) applytextattributes(TSC_PROMPT); break; case 'H': - bv->fm = parsehighlight(bv->fm + 2, '}', &atr); - if (atr != TXT_ERROR) { - treplaceattrs(atr); - applytextattributes(TSC_PROMPT); + if (bv->fm[1] == '{') { + bv->fm = parsehighlight(bv->fm + 2, '}', &atr); + if (atr != TXT_ERROR) { + treplaceattrs(atr); + applytextattributes(TSC_PROMPT); + } } break; case '[': |