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