Compare commits

...

No commits in common. "c8" and "c9-beta" have entirely different histories.
c8 ... c9-beta

12 changed files with 209 additions and 1949 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/zsh-5.5.1.tar.xz SOURCES/zsh-5.8.tar.xz

View File

@ -1 +1 @@
98ea952bba9b8752635c75f54bcecef072d3036e SOURCES/zsh-5.5.1.tar.xz 966ea0498fb94140f3caf12af88e98b0e4d02078 SOURCES/zsh-5.8.tar.xz

View File

@ -1,148 +0,0 @@
From ddb6c5b4c0ab9c6a7404112d367f0c7cc400ceec Mon Sep 17 00:00:00 2001
From: Anthony Sottile <asottile@umich.edu>
Date: Mon, 3 Sep 2018 14:39:25 +0000
Subject: [PATCH] CVE-2018-0502, CVE-2018-13259: Fix two security issues in
shebang line parsing.
See NEWS for more information.
Patch by Anthony Sottile and Buck Evan.
Upstream-commit: 1c4c7b6a4d17294df028322b70c53803a402233d
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
Etc/FAQ.yo | 2 +-
Src/exec.c | 36 ++++++++++++++++++++----------------
Test/A05execution.ztst | 22 ++++++++++++++++++++++
3 files changed, 43 insertions(+), 17 deletions(-)
diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo
index 72ff7fa..8552fe7 100644
--- a/Etc/FAQ.yo
+++ b/Etc/FAQ.yo
@@ -306,7 +306,7 @@ sect(On what machines will it run?)
sect(What's the latest version?)
- Zsh 5.5.1 is the latest production version. For details of all the
+ Zsh 5.6 is the latest production version. For details of all the
changes, see the NEWS file in the source distribution.
A beta of the next version is sometimes available. Development of zsh is
diff --git a/Src/exec.c b/Src/exec.c
index 216057a..0908a1a 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -453,7 +453,7 @@ execcursh(Estate state, int do_exec)
/* execve after handling $_ and #! */
-#define POUNDBANGLIMIT 64
+#define POUNDBANGLIMIT 128
/**/
static int
@@ -494,18 +494,20 @@ zexecve(char *pth, char **argv, char **newenvp)
if ((fd = open(pth, O_RDONLY|O_NOCTTY)) >= 0) {
argv0 = *argv;
*argv = pth;
- execvebuf[0] = '\0';
+ memset(execvebuf, '\0', POUNDBANGLIMIT + 1);
ct = read(fd, execvebuf, POUNDBANGLIMIT);
close(fd);
if (ct >= 0) {
- if (execvebuf[0] == '#') {
- if (execvebuf[1] == '!') {
- for (t0 = 0; t0 != ct; t0++)
- if (execvebuf[t0] == '\n')
- break;
+ if (ct >= 2 && execvebuf[0] == '#' && execvebuf[1] == '!') {
+ for (t0 = 0; t0 != ct; t0++)
+ if (execvebuf[t0] == '\n')
+ break;
+ if (t0 == ct)
+ zerr("%s: bad interpreter: %s: %e", pth,
+ execvebuf + 2, eno);
+ else {
while (inblank(execvebuf[t0]))
execvebuf[t0--] = '\0';
- execvebuf[POUNDBANGLIMIT] = '\0';
for (ptr = execvebuf + 2; *ptr && *ptr == ' '; ptr++);
for (ptr2 = ptr; *ptr && *ptr != ' '; ptr++);
if (eno == ENOENT) {
@@ -514,10 +516,16 @@ zexecve(char *pth, char **argv, char **newenvp)
*ptr = '\0';
if (*ptr2 != '/' &&
(pprog = pathprog(ptr2, NULL))) {
- argv[-2] = ptr2;
- argv[-1] = ptr + 1;
- winch_unblock();
- execve(pprog, argv - 2, newenvp);
+ if (ptr == execvebuf + t0 + 1) {
+ argv[-1] = ptr2;
+ winch_unblock();
+ execve(pprog, argv - 1, newenvp);
+ } else {
+ argv[-2] = ptr2;
+ argv[-1] = ptr + 1;
+ winch_unblock();
+ execve(pprog, argv - 2, newenvp);
+ }
}
zerr("%s: bad interpreter: %s: %e", pth, ptr2,
eno);
@@ -532,10 +540,6 @@ zexecve(char *pth, char **argv, char **newenvp)
winch_unblock();
execve(ptr2, argv - 1, newenvp);
}
- } else if (eno == ENOEXEC) {
- argv[-1] = "sh";
- winch_unblock();
- execve("/bin/sh", argv - 1, newenvp);
}
} else if (eno == ENOEXEC) {
for (t0 = 0; t0 != ct; t0++)
diff --git a/Test/A05execution.ztst b/Test/A05execution.ztst
index 0804691..fb39d05 100644
--- a/Test/A05execution.ztst
+++ b/Test/A05execution.ztst
@@ -12,7 +12,14 @@
print '#!/bin/sh\necho This is dir2' >dir2/tstcmd
+ print -n '#!sh\necho This is slashless' >tstcmd-slashless
+ print -n '#!echo foo\necho This is arg' >tstcmd-arg
+ print '#!xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxnyyy' >tstcmd-interp-too-long
+ print '#!/bin/sh\necho should not execute; exit 1' >xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxn
+
chmod 755 tstcmd dir1/tstcmd dir2/tstcmd
+ chmod 755 tstcmd-slashless tstcmd-arg tstcmd-interp-too-long
+ chmod 755 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxn
%test
./tstcmd
@@ -33,6 +40,21 @@
0:path (2)
>This is top
+ PATH=/bin:${ZTST_testdir}/command.tmp/ tstcmd-slashless
+0:path (3)
+>This is slashless
+
+ PATH=/bin:${ZTST_testdir}/command.tmp tstcmd-arg
+0:path (4)
+*>foo */command.tmp/tstcmd-arg
+
+ path=(/bin ${ZTST_testdir}/command.tmp/)
+ tstcmd-interp-too-long 2>&1; echo "status $?"
+ path=($storepath)
+0:path (5)
+*>*tstcmd-interp-too-long: bad interpreter: x*xn: no such file or directory
+>status 127
+
functst() { print $# arguments:; print -l $*; }
functst "Eines Morgens" "als Gregor Samsa"
functst ""
--
2.17.1

View File

@ -0,0 +1,27 @@
From d8ec07a4779f4675139c650979eb87dd6d7a5d92 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@daniel.shahaf.name>
Date: Tue, 18 Aug 2020 13:30:04 +0000
Subject: [PATCH] 47323: _rpmbuild: Complete file arguments after -r/-b/-t.
Upstream-commit: e14e899ab96c4171544a244ddc39991512ec41c8
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
Completion/Redhat/Command/_rpm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Completion/Redhat/Command/_rpm b/Completion/Redhat/Command/_rpm
index e346924..db7c114 100644
--- a/Completion/Redhat/Command/_rpm
+++ b/Completion/Redhat/Command/_rpm
@@ -282,7 +282,7 @@ _rpm () {
build_r) tmp=( '*:source package:_files -g "*.(#i)src.rpm(-.)"' ) ;|
build_t) tmp=( '*:tar file:_files -g "*.(#i)tar(.*|)(-.)"' ) ;|
build_?)
- _arguments -s -C $buildopts $commonopts $pathopts \
+ _arguments -s -C $buildopts $commonopts $pathopts "${tmp[@]}" \
;;
checksig)
_arguments -s -C \!-K \
--
2.26.3

View File

@ -1,266 +0,0 @@
From bc943b78268ad633f79756639d4295f7b61dbedd Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Wed, 7 Nov 2018 14:04:52 +0100
Subject: [PATCH 1/5] 43791: File descriptor could be closed twice in clone
Upstream-commit: a8cc017c74a916b690dc074c299faf4bd24b5af4
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
Error: USE_AFTER_FREE (CWE-825):
zsh-5.5.1/Src/Modules/clone.c:71: closed_arg: "close(int)" closes "ttyfd".
zsh-5.5.1/Src/Modules/clone.c:99: double_close: Calling "close(int)" closes handle "ttyfd" which has already been closed.
97| setsparam("TTY", ztrdup(ttystrname));
98| }
99|-> close(ttyfd);
100| if (pid < 0) {
101| zerrnam(nam, "fork failed: %e", errno);
---
Src/Modules/clone.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Src/Modules/clone.c b/Src/Modules/clone.c
index 9304292..dfd8e8a 100644
--- a/Src/Modules/clone.c
+++ b/Src/Modules/clone.c
@@ -96,7 +96,8 @@ bin_clone(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
init_io(NULL);
setsparam("TTY", ztrdup(ttystrname));
}
- close(ttyfd);
+ else
+ close(ttyfd);
if (pid < 0) {
zerrnam(nam, "fork failed: %e", errno);
return 1;
--
2.17.2
From 6096988f02635ed336a056e3670b63070400e6bc Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Wed, 7 Nov 2018 14:04:53 +0100
Subject: [PATCH 2/5] 43793: computil could overrun buffer
Upstream-commit: 031afe420725e328e9d7742be69ef0bd81c62b9a
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
Error: BUFFER_SIZE (CWE-120):
zsh-5.5.1/Src/Zle/computil.c:564: overlapping_buffer: The source buffer "str->str + 2" potentially overlaps with the destination buffer "str->str", which results in undefined behavior for "strcpy".
zsh-5.5.1/Src/Zle/computil.c:564: remediation: Replace "strcpy(dest, src)" with "memmove(dest, src, strlen(src)+1)".
562| str->str = ztrdup(str->str);
563| if (hide[1] && str->str[0] == '-' && str->str[1] == '-')
564|-> strcpy(str->str, str->str + 2);
565| else if (str->str[0] == '-' || str->str[0] == '+')
566| strcpy(str->str, str->str + 1);
Error: BUFFER_SIZE (CWE-120):
zsh-5.5.1/Src/Zle/computil.c:566: overlapping_buffer: The source buffer "str->str + 1" potentially overlaps with the destination buffer "str->str", which results in undefined behavior for "strcpy".
zsh-5.5.1/Src/Zle/computil.c:566: remediation: Replace "strcpy(dest, src)" with "memmove(dest, src, strlen(src)+1)".
564| strcpy(str->str, str->str + 2);
565| else if (str->str[0] == '-' || str->str[0] == '+')
566|-> strcpy(str->str, str->str + 1);
567| }
568| }
---
Src/Zle/computil.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index 5526e0a..cb1c010 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -561,9 +561,9 @@ cd_init(char *nam, char *hide, char *mlen, char *sep,
if (str->str == str->match)
str->str = ztrdup(str->str);
if (hide[1] && str->str[0] == '-' && str->str[1] == '-')
- strcpy(str->str, str->str + 2);
+ memmove(str->str, str->str + 2, strlen(str->str) - 1);
else if (str->str[0] == '-' || str->str[0] == '+')
- strcpy(str->str, str->str + 1);
+ memmove(str->str, str->str + 1, strlen(str->str));
}
}
for (ap = args; *args &&
--
2.17.2
From 29445bdf10714bd41d2124d3c31cc16c1f682854 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Wed, 7 Nov 2018 14:04:54 +0100
Subject: [PATCH 3/5] 43723: file descriptor could leak on fork error
Upstream-commit: d1095bdf744c190c7e8ff126ba02caea8f63880d
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
Error: RESOURCE_LEAK (CWE-772):
zsh-5.5.1/Src/exec.c:4680: open_fn: Returning handle opened by "open".
zsh-5.5.1/Src/exec.c:4680: var_assign: Assigning: "fd" = handle returned from "open(nam, 449, 384)".
zsh-5.5.1/Src/exec.c:4810: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
4808| /* fork or open error */
4809| child_unblock();
4810|-> return nam;
4811| } else if (pid) {
4812| int os;
---
Src/exec.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Src/exec.c b/Src/exec.c
index 0908a1a..8045db2 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -4722,7 +4722,8 @@ getoutputfile(char *cmd, char **eptr)
}
if ((cmdoutpid = pid = zfork(NULL)) == -1) {
- /* fork or open error */
+ /* fork error */
+ close(fd);
child_unblock();
return nam;
} else if (pid) {
--
2.17.2
From afb4192a75066f86ce7051a72c0feb7b80c0cdd8 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Wed, 7 Nov 2018 14:04:55 +0100
Subject: [PATCH 4/5] 43789: possible use after free clearing up math func from
module
Upstream-commit: e27175c7c8cdfeb4e28d4ff21eb51aa003d70a03
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
Error: USE_AFTER_FREE (CWE-825):
zsh-5.5.1/Src/module.c:1390: freed_arg: "deletemathfunc" frees "f".
zsh-5.5.1/Src/module.c:1352:6: freed_arg: "zfree" frees parameter "f".
zsh-5.5.1/Src/mem.c:1888:5: freed_arg: "free" frees parameter "p".
zsh-5.5.1/Src/module.c:1394: deref_after_free: Dereferencing freed pointer "f".
1392| ret = 1;
1393| } else {
1394|-> f->flags &= ~MFF_ADDED;
1395| }
1396| }
---
Src/module.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/Src/module.c b/Src/module.c
index 4ae7831..33d75eb 100644
--- a/Src/module.c
+++ b/Src/module.c
@@ -1390,8 +1390,6 @@ setmathfuncs(char const *nam, MathFunc f, int size, int *e)
if (deletemathfunc(f)) {
zwarnnam(nam, "math function `%s' already deleted", f->name);
ret = 1;
- } else {
- f->flags &= ~MFF_ADDED;
}
}
f++;
--
2.17.2
From 4553645c00d9a2e81a79e2014b106f6590500287 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Wed, 7 Nov 2018 14:04:56 +0100
Subject: [PATCH 5/5] 43790: failed mailstat could leak memory
Upstream-commit: d50e204b0c4c10164a711bf640500e46987de9c3
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
Error: RESOURCE_LEAK (CWE-772):
zsh-5.5.1/Src/utils.c:7406: alloc_fn: Storage is returned from allocation function "appstr".
zsh-5.5.1/Src/string.c:200:5: alloc_fn: Storage is returned from allocation function "realloc".
zsh-5.5.1/Src/string.c:200:5: identity_transfer: Passing "realloc(base, strlen(base) + strlen(append) + 1UL)" as argument 1 to function "strcat", which returns that argument.
zsh-5.5.1/Src/string.c:200:5: return_alloc_fn: Directly returning storage allocated by "strcat".
zsh-5.5.1/Src/utils.c:7406: var_assign: Assigning: "dir" = storage returned from "appstr(ztrdup(path), "/cur")".
zsh-5.5.1/Src/utils.c:7407: noescape: Resource "dir" is not freed or pointed-to in "stat".
zsh-5.5.1/Src/utils.c:7407: leaked_storage: Variable "dir" going out of scope leaks the storage it points to.
7405| /* See if cur/ is present */
7406| dir = appstr(ztrdup(path), "/cur");
7407|-> if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) return 0;
7408| st_ret.st_atime = st_tmp.st_atime;
7409|
Error: RESOURCE_LEAK (CWE-772):
zsh-5.5.1/Src/utils.c:7412: alloc_fn: Storage is returned from allocation function "appstr".
zsh-5.5.1/Src/string.c:200:5: alloc_fn: Storage is returned from allocation function "realloc".
zsh-5.5.1/Src/string.c:200:5: identity_transfer: Passing "realloc(base, strlen(base) + strlen(append) + 1UL)" as argument 1 to function "strcat", which returns that argument.
zsh-5.5.1/Src/string.c:200:5: return_alloc_fn: Directly returning storage allocated by "strcat".
zsh-5.5.1/Src/utils.c:7412: var_assign: Assigning: "dir" = storage returned from "appstr(dir, "/tmp")".
zsh-5.5.1/Src/utils.c:7413: noescape: Resource "dir" is not freed or pointed-to in "stat".
zsh-5.5.1/Src/utils.c:7413: leaked_storage: Variable "dir" going out of scope leaks the storage it points to.
7411| dir[plen] = 0;
7412| dir = appstr(dir, "/tmp");
7413|-> if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) return 0;
7414| st_ret.st_mtime = st_tmp.st_mtime;
7415|
Error: RESOURCE_LEAK (CWE-772):
zsh-5.5.1/Src/utils.c:7418: alloc_fn: Storage is returned from allocation function "appstr".
zsh-5.5.1/Src/string.c:200:5: alloc_fn: Storage is returned from allocation function "realloc".
zsh-5.5.1/Src/string.c:200:5: identity_transfer: Passing "realloc(base, strlen(base) + strlen(append) + 1UL)" as argument 1 to function "strcat", which returns that argument.
zsh-5.5.1/Src/string.c:200:5: return_alloc_fn: Directly returning storage allocated by "strcat".
zsh-5.5.1/Src/utils.c:7418: var_assign: Assigning: "dir" = storage returned from "appstr(dir, "/new")".
zsh-5.5.1/Src/utils.c:7419: noescape: Resource "dir" is not freed or pointed-to in "stat".
zsh-5.5.1/Src/utils.c:7419: leaked_storage: Variable "dir" going out of scope leaks the storage it points to.
7417| dir[plen] = 0;
7418| dir = appstr(dir, "/new");
7419|-> if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) return 0;
7420| st_ret.st_mtime = st_tmp.st_mtime;
7421|
---
Src/utils.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/Src/utils.c b/Src/utils.c
index b418517..492babc 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -7404,19 +7404,28 @@ mailstat(char *path, struct stat *st)
/* See if cur/ is present */
dir = appstr(ztrdup(path), "/cur");
- if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) return 0;
+ if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) {
+ zsfree(dir);
+ return 0;
+ }
st_ret.st_atime = st_tmp.st_atime;
/* See if tmp/ is present */
dir[plen] = 0;
dir = appstr(dir, "/tmp");
- if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) return 0;
+ if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) {
+ zsfree(dir);
+ return 0;
+ }
st_ret.st_mtime = st_tmp.st_mtime;
/* And new/ */
dir[plen] = 0;
dir = appstr(dir, "/new");
- if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) return 0;
+ if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) {
+ zsfree(dir);
+ return 0;
+ }
st_ret.st_mtime = st_tmp.st_mtime;
#if THERE_IS_EXACTLY_ONE_MAILDIR_IN_MAILPATH
@@ -7428,6 +7437,7 @@ mailstat(char *path, struct stat *st)
st_tmp.st_atime == st_new_last.st_atime &&
st_tmp.st_mtime == st_new_last.st_mtime) {
*st = st_ret_last;
+ zsfree(dir);
return 0;
}
st_new_last = st_tmp;
--
2.17.2

View File

@ -0,0 +1,109 @@
From 02e0f94fff27cad2ba4e65bdc4b21146b3bd9a97 Mon Sep 17 00:00:00 2001
From: Oliver Kiddle <opk@zsh.org>
Date: Wed, 15 Dec 2021 01:56:40 +0100
Subject: [PATCH 1/2] security/41: Don't perform PROMPT_SUBST evaluation on
%F/%K arguments
Mitigates CVE-2021-45444
Upstream-commit: c187154f47697cdbf822c2f9d714d570ed4a0fd1
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
Src/prompt.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/Src/prompt.c b/Src/prompt.c
index b65bfb8..91e21c8 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -244,6 +244,12 @@ parsecolorchar(zattr arg, int is_fg)
bv->fm += 2; /* skip over F{ */
if ((ep = strchr(bv->fm, '}'))) {
char oc = *ep, *col, *coll;
+ int ops = opts[PROMPTSUBST], opb = opts[PROMPTBANG];
+ int opp = opts[PROMPTPERCENT];
+
+ opts[PROMPTPERCENT] = 1;
+ opts[PROMPTSUBST] = opts[PROMPTBANG] = 0;
+
*ep = '\0';
/* expand the contents of the argument so you can use
* %v for example */
@@ -252,6 +258,10 @@ parsecolorchar(zattr arg, int is_fg)
arg = match_colour((const char **)&coll, is_fg, 0);
free(col);
bv->fm = ep;
+
+ opts[PROMPTSUBST] = ops;
+ opts[PROMPTBANG] = opb;
+ opts[PROMPTPERCENT] = opp;
} else {
arg = match_colour((const char **)&bv->fm, is_fg, 0);
if (*bv->fm != '}')
--
2.34.1
From 6102afb5dfd7c704f9cf99bedb9c3ec3c7dbe8e3 Mon Sep 17 00:00:00 2001
From: dana <dana@dana.is>
Date: Tue, 21 Dec 2021 13:13:33 -0600
Subject: [PATCH 2/2] CVE-2021-45444: Update NEWS/README
Upstream-commit: bdc4d70a7e033b754e68a8659a037ea0fc5f38de
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
NEWS | 20 ++++++++++++++++++++
README | 6 ++++++
2 files changed, 26 insertions(+)
diff --git a/NEWS b/NEWS
index 964e163..327b449 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,26 @@ CHANGES FROM PREVIOUS VERSIONS OF ZSH
Note also the list of incompatibilities in the README file.
+Changes since 5.8
+-----------------
+
+CVE-2021-45444: Some prompt expansion sequences, such as %F, support
+'arguments' which are themselves expanded in case they contain colour
+values, etc. This additional expansion would trigger PROMPT_SUBST
+evaluation, if enabled. This could be abused to execute code the user
+didn't expect. e.g., given a certain prompt configuration, an attacker
+could trick a user into executing arbitrary code by having them check
+out a Git branch with a specially crafted name.
+
+This is fixed in the shell itself by no longer performing PROMPT_SUBST
+evaluation on these prompt-expansion arguments.
+
+Users who are concerned about an exploit but unable to update their
+binaries may apply the partial work-around described in the file
+Etc/CVE-2021-45444-VCS_Info-workaround.patch included with the shell
+source. [ Reported by RyotaK <security@ryotak.me>. Additional thanks to
+Marc Cornellà <hello@mcornella.com>. ]
+
Changes since 5.7.1-test-3
--------------------------
diff --git a/README b/README
index 7f1dd5f..c9e994a 100644
--- a/README
+++ b/README
@@ -31,6 +31,12 @@ Zsh is a shell with lots of features. For a list of some of these, see the
file FEATURES, and for the latest changes see NEWS. For more
details, see the documentation.
+Incompatibilities since 5.8
+---------------------------
+
+PROMPT_SUBST expansion is no longer performed on arguments to prompt-
+expansion sequences such as %F.
+
Incompatibilities since 5.7.1
-----------------------------
--
2.34.1

View File

@ -1,28 +0,0 @@
From 878ebe3c74cee4b9702c9672b87ee56f057e1f02 Mon Sep 17 00:00:00 2001
From: Peter Stephenson <p.stephenson@samsung.com>
Date: Thu, 29 Nov 2018 17:54:02 +0000
Subject: [PATCH] 43854: Set tok to LEXERR on generic parse error.
Needed by main loop which detects an error this way.
Upstream-commit: ef20425381e83ebd5a10c2ab270a347018371162
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
Src/lex.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/Src/lex.c b/Src/lex.c
index 44ad880..c29aaba 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -1613,6 +1613,7 @@ parsestr(char **s)
zerr("parse error near `%c'", err);
else
zerr("parse error");
+ tok = LEXERR;
}
}
return err;
--
2.17.2

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -1,28 +0,0 @@
From 6af0b07cc7950159129156cb85ef3f72fdd828cc Mon Sep 17 00:00:00 2001
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
Date: Sat, 3 Aug 2019 19:48:18 +0100
Subject: [PATCH] 44635: Don't apply STAT_NOPRINT to backgrounded jobs
Upstream-commit: e0d063a2ade821baf570eb300d4be93692b494f8
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
Src/exec.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Src/exec.c b/Src/exec.c
index 8045db2..da089d6 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1666,7 +1666,8 @@ execpline(Estate state, wordcode slcode, int how, int last1)
lastwj = thisjob = newjob;
- if (list_pipe || (pline_level && !(how & Z_TIMED)))
+ if (list_pipe || (pline_level && !(how & Z_TIMED) &&
+ !(jn->stat & STAT_NOSTTY)))
jn->stat |= STAT_NOPRINT;
if (nowait) {
--
2.34.1

View File

@ -8,7 +8,7 @@
#setenv() { export $1=$2 } # csh compatibility #setenv() { export $1=$2 } # csh compatibility
# Set prompts # Set prompts
PROMPT='[%n@%m]%~%# ' # default prompt [[ "$PROMPT" = "%m%# " ]] && PROMPT='[%n@%m]%~%# ' # default prompt
#RPROMPT=' %~' # prompt for right side of screen #RPROMPT=' %~' # prompt for right side of screen
# bindkey -v # vi key bindings # bindkey -v # vi key bindings

View File

@ -1,7 +1,7 @@
Summary: Powerful interactive shell Summary: Powerful interactive shell
Name: zsh Name: zsh
Version: 5.5.1 Version: 5.8
Release: 10%{?dist} Release: 9%{?dist}
License: MIT License: MIT
URL: http://zsh.sourceforge.net/ URL: http://zsh.sourceforge.net/
Source0: https://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.xz Source0: https://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.xz
@ -12,37 +12,26 @@ Source4: zshrc.rhs
Source5: zshenv.rhs Source5: zshenv.rhs
Source6: dotzshrc Source6: dotzshrc
# fix two security issues in shebang line parsing (CVE-2018-0502 CVE-2018-13259) # complete file arguments after rpmbuild -r/-b/-t
Patch1: 0001-zsh-5.5.1-CVE-2018-0502-CVE-2018-13259.patch Patch1: 0001-zsh-5.8-comp-rpm.patch
# fix programming mistakes detected by static analysis (#1602743)
Patch2: 0002-zsh-5.5.1-static-analysis.patch
# return non-zero exit status on nested parse error (#1654989)
Patch3: 0003-zsh-5.5.1-parse-error-exit-status.patch
# drop privileges securely when unsetting PRIVILEGED option (CVE-2019-20044)
Patch4: 0004-zsh-5.5.1-CVE-2019-20044.patch
# do not perform PROMPT_SUBST evaluation on %F/%K arguments (CVE-2021-45444) # do not perform PROMPT_SUBST evaluation on %F/%K arguments (CVE-2021-45444)
Patch5: 0005-zsh-5.5.1-CVE-2021-45444.patch Patch2: 0002-zsh-5.8-CVE-2021-45444.patch
# make zsh wait built-in wait properly for all active child processes (#2070342)
Patch6: 0006-zsh-5.5.1-fix-wait.patch
BuildRequires: autoconf BuildRequires: autoconf
BuildRequires: coreutils BuildRequires: coreutils
BuildRequires: gawk BuildRequires: gawk
BuildRequires: gcc BuildRequires: gcc
BuildRequires: gdbm-devel BuildRequires: gdbm-devel
BuildRequires: glibc-langpack-ja
BuildRequires: libcap-devel BuildRequires: libcap-devel
BuildRequires: make
BuildRequires: ncurses-devel BuildRequires: ncurses-devel
BuildRequires: pcre-devel BuildRequires: pcre-devel
BuildRequires: sed BuildRequires: sed
BuildRequires: texi2html BuildRequires: texi2html
BuildRequires: texinfo BuildRequires: texinfo
Requires(post): info grep Requires(post): grep
Requires(preun): info
Requires(postun): coreutils grep Requires(postun): coreutils grep
# the hostname package is not available on RHEL-6 # the hostname package is not available on RHEL-6
@ -91,6 +80,9 @@ sed -e 's|^\.NOTPARALLEL|#.NOTPARALLEL|' -i 'Config/defs.mk.in'
# make loading of module's dependencies work again (#1277996) # make loading of module's dependencies work again (#1277996)
export LIBLDFLAGS='-z lazy' export LIBLDFLAGS='-z lazy'
# avoid build failure in case we have working ypcat (#1687574)
export zsh_cv_sys_nis='no'
%configure \ %configure \
--enable-etcdir=%{_sysconfdir} \ --enable-etcdir=%{_sysconfdir} \
--with-tcsetpgrp \ --with-tcsetpgrp \
@ -101,7 +93,7 @@ export LIBLDFLAGS='-z lazy'
make -C Src headers make -C Src headers
make -C Src -f Makemod zsh{path,xmod}s.h version.h make -C Src -f Makemod zsh{path,xmod}s.h version.h
make %{?_smp_mflags} all html %make_build all html
%check %check
# Run the testsuite # Run the testsuite
@ -147,22 +139,6 @@ if [ "$1" = 1 ]; then
fi fi
fi fi
if [ -f %{_infodir}/zsh.info.gz ]; then
# This is needed so that --excludedocs works.
/sbin/install-info %{_infodir}/zsh.info.gz %{_infodir}/dir \
--entry="* zsh: (zsh). An enhanced bourne shell."
fi
%preun
if [ "$1" = 0 ] ; then
if [ -f %{_infodir}/zsh.info.gz ]; then
# This is needed so that --excludedocs works.
/sbin/install-info --delete %{_infodir}/zsh.info.gz %{_infodir}/dir \
--entry="* zsh: (zsh). An enhanced bourne shell."
fi
fi
%postun %postun
if [ "$1" = 0 ] && [ -f %{_sysconfdir}/shells ] ; then if [ "$1" = 0 ] && [ -f %{_sysconfdir}/shells ] ; then
sed -i '\!^%{_bindir}/%{name}$!d' %{_sysconfdir}/shells sed -i '\!^%{_bindir}/%{name}$!d' %{_sysconfdir}/shells
@ -185,32 +161,73 @@ fi
%doc Doc/*.html %doc Doc/*.html
%changelog %changelog
* Fri Apr 01 2022 Kamil Dudka <kdudka@redhat.com> - 5.5.1-10 * Tue Feb 22 2022 Kamil Dudka <kdudka@redhat.com> - 5.8-9
- make zsh wait built-in wait properly for all active child processes (#2070342)
* Tue Feb 22 2022 Kamil Dudka <kdudka@redhat.com> - 5.5.1-9
- do not perform PROMPT_SUBST evaluation on %F/%K arguments (CVE-2021-45444) - do not perform PROMPT_SUBST evaluation on %F/%K arguments (CVE-2021-45444)
* Tue Mar 03 2020 Kamil Dudka <kdudka@redhat.com> - 5.5.1-8 * Thu Nov 25 2021 Debarshi Ray <rishi@fedoraproject.org> - 5.8-8
- improve printing of error messages introduced by the fix of CVE-2019-20044 - Overwrite PROMPT only if it's set to the built-in default (#2026749)
* Mon Feb 24 2020 Kamil Dudka <kdudka@redhat.com> - 5.5.1-7 * Tue Aug 10 2021 Mohan Boddu <mboddu@redhat.com> - 5.8-7
- drop privileges securely when unsetting PRIVILEGED option (CVE-2019-20044) - Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Mon Dec 17 2018 Kamil Dudka <kdudka@redhat.com> - 5.5.1-6 * Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 5.8-6
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Thu Mar 25 2021 Kamil Dudka <kdudka@redhat.com> - 5.8-5
- complete file arguments after rpmbuild -r/-b/-t
* Thu Jan 28 2021 Fedora Release Engineering <releng@fedoraproject.org> - 5.8-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 5.8-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Tue Jul 14 2020 Tom Stellard <tstellar@redhat.com> - 5.8-2
- Use make macros
- https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro
* Mon Feb 24 2020 Kamil Dudka <kdudka@redhat.com> - 5.8-1
- update to latest upstream release
* Fri Jan 31 2020 Fedora Release Engineering <releng@fedoraproject.org> - 5.7.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Fri Jul 26 2019 Kamil Dudka <kdudka@redhat.com> - 5.7.1-4
- make failed searches of history in Zle robust (#1722703)
* Tue Mar 12 2019 Kamil Dudka <kdudka@redhat.com> - 5.7.1-3
- avoid build failure in case we have working ypcat (#1687574)
* Fri Mar 8 2019 Tim Landscheidt <tim@tim-landscheidt.de> - 5.7.1-2
- Remove obsolete requirements for %%post/%%preun scriptlets
* Mon Feb 04 2019 Kamil Dudka <kdudka@redhat.com> - 5.7.1-1
- update to latest upstream release
* Sun Feb 03 2019 Fedora Release Engineering <releng@fedoraproject.org> - 5.7-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Mon Jan 28 2019 Jason L Tibbitts III <tibbs@math.uh.edu> - 5.7-1
- Update to latest upstream release.
* Fri Nov 30 2018 Kamil Dudka <kdudka@redhat.com> - 5.6.2-3
- return non-zero exit status on nested parse error (#1654989) - return non-zero exit status on nested parse error (#1654989)
* Mon Nov 12 2018 Kamil Dudka <kdudka@redhat.com> - 5.5.1-5 * Mon Nov 12 2018 Kamil Dudka <kdudka@redhat.com> - 5.6.2-2
- fix programming mistakes detected by static analysis (#1602743) - fix programming mistakes detected by static analysis
* Thu Oct 11 2018 Kamil Dudka <kdudka@redhat.com> - 5.5.1-4 * Fri Sep 14 2018 Kamil Dudka <kdudka@redhat.com> - 5.6.2-1
- fix two security issues in shebang line parsing (CVE-2018-0502 CVE-2018-13259) - update to latest upstream release
* Mon Jul 30 2018 Florian Weimer <fweimer@redhat.com> - 5.5.1-3 * Mon Sep 10 2018 Kamil Dudka <kdudka@redhat.com> - 5.6.1-1
- Rebuild with fixed binutils - update to latest upstream release
* Wed Jul 25 2018 Petr Kubat <pkubat@redhat.com> - 5.5.1-2 * Tue Sep 04 2018 Kamil Dudka <kdudka@redhat.com> - 5.6-1
- Rebuilt for gdbm - update to latest upstream release (fixes CVE-2018-0502 and CVE-2018-13259)
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 5.5.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Tue Apr 17 2018 Kamil Dudka <kdudka@redhat.com> - 5.5.1-1 * Tue Apr 17 2018 Kamil Dudka <kdudka@redhat.com> - 5.5.1-1
- update to latest upstream release - update to latest upstream release