|
|
683310 |
From 9ce87af4ced4e21258e6003f1fb65b05ca5a7d14 Mon Sep 17 00:00:00 2001
|
|
|
683310 |
From: Oliver Kiddle <opk@zsh.org>
|
|
|
683310 |
Date: Wed, 15 Dec 2021 01:56:40 +0100
|
|
|
683310 |
Subject: [PATCH] security/41: Don't perform PROMPT_SUBST evaluation on %F/%K
|
|
|
683310 |
arguments
|
|
|
683310 |
|
|
|
683310 |
Mitigates CVE-2021-45444
|
|
|
683310 |
|
|
|
683310 |
Upstream-commit: c187154f47697cdbf822c2f9d714d570ed4a0fd1
|
|
|
683310 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
683310 |
---
|
|
|
683310 |
Src/prompt.c | 10 ++++++++++
|
|
|
683310 |
1 file changed, 10 insertions(+)
|
|
|
683310 |
|
|
|
683310 |
diff --git a/Src/prompt.c b/Src/prompt.c
|
|
|
683310 |
index 95da525..1368f8e 100644
|
|
|
683310 |
--- a/Src/prompt.c
|
|
|
683310 |
+++ b/Src/prompt.c
|
|
|
683310 |
@@ -244,6 +244,12 @@ parsecolorchar(int arg, int is_fg)
|
|
|
683310 |
bv->fm += 2; /* skip over F{ */
|
|
|
683310 |
if ((ep = strchr(bv->fm, '}'))) {
|
|
|
683310 |
char oc = *ep, *col, *coll;
|
|
|
683310 |
+ int ops = opts[PROMPTSUBST], opb = opts[PROMPTBANG];
|
|
|
683310 |
+ int opp = opts[PROMPTPERCENT];
|
|
|
683310 |
+
|
|
|
683310 |
+ opts[PROMPTPERCENT] = 1;
|
|
|
683310 |
+ opts[PROMPTSUBST] = opts[PROMPTBANG] = 0;
|
|
|
683310 |
+
|
|
|
683310 |
*ep = '\0';
|
|
|
683310 |
/* expand the contents of the argument so you can use
|
|
|
683310 |
* %v for example */
|
|
|
683310 |
@@ -252,6 +258,10 @@ parsecolorchar(int arg, int is_fg)
|
|
|
683310 |
arg = match_colour((const char **)&coll, is_fg, 0);
|
|
|
683310 |
free(col);
|
|
|
683310 |
bv->fm = ep;
|
|
|
683310 |
+
|
|
|
683310 |
+ opts[PROMPTSUBST] = ops;
|
|
|
683310 |
+ opts[PROMPTBANG] = opb;
|
|
|
683310 |
+ opts[PROMPTPERCENT] = opp;
|
|
|
683310 |
} else {
|
|
|
683310 |
arg = match_colour((const char **)&bv->fm, is_fg, 0);
|
|
|
683310 |
if (*bv->fm != '}')
|
|
|
683310 |
--
|
|
|
683310 |
2.34.1
|
|
|
683310 |
|