Blame SOURCES/zsh-5.0.2-CVE-2018-1071.patch
|
|
560f4e |
From c3fec0b136d938704d8b0ba82424eea8d17f86ab Mon Sep 17 00:00:00 2001
|
|
|
560f4e |
From: Oliver Kiddle <okiddle@yahoo.co.uk>
|
|
|
560f4e |
Date: Sat, 24 Mar 2018 15:02:41 +0100
|
|
|
560f4e |
Subject: [PATCH] 42518, CVE-2018-1071: check bounds when copying path in
|
|
|
560f4e |
hashcmd()
|
|
|
560f4e |
|
|
|
560f4e |
Upstream-commit: 679b71ec4d852037fe5f73d35bf557b0f406c8d4
|
|
|
560f4e |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
560f4e |
---
|
|
|
560f4e |
Src/exec.c | 2 +-
|
|
|
560f4e |
Src/utils.c | 6 +++---
|
|
|
560f4e |
2 files changed, 4 insertions(+), 4 deletions(-)
|
|
|
560f4e |
|
|
|
560f4e |
diff --git a/Src/exec.c b/Src/exec.c
|
|
|
560f4e |
index 6d47935..b9ffb35 100644
|
|
|
560f4e |
--- a/Src/exec.c
|
|
|
560f4e |
+++ b/Src/exec.c
|
|
|
560f4e |
@@ -860,7 +860,7 @@ hashcmd(char *arg0, char **pp)
|
|
|
560f4e |
for (; *pp; pp++)
|
|
|
560f4e |
if (**pp == '/') {
|
|
|
560f4e |
s = buf;
|
|
|
560f4e |
- strucpy(&s, *pp);
|
|
|
560f4e |
+ struncpy(&s, *pp, PATH_MAX);
|
|
|
560f4e |
*s++ = '/';
|
|
|
560f4e |
if ((s - buf) + strlen(arg0) >= PATH_MAX)
|
|
|
560f4e |
continue;
|
|
|
560f4e |
diff --git a/Src/utils.c b/Src/utils.c
|
|
|
560f4e |
index 391d020..c6eba63 100644
|
|
|
560f4e |
--- a/Src/utils.c
|
|
|
560f4e |
+++ b/Src/utils.c
|
|
|
560f4e |
@@ -2005,10 +2005,10 @@ struncpy(char **s, char *t, int n)
|
|
|
560f4e |
{
|
|
|
560f4e |
char *u = *s;
|
|
|
560f4e |
|
|
|
560f4e |
- while (n--)
|
|
|
560f4e |
- *u++ = *t++;
|
|
|
560f4e |
+ while (n-- && (*u++ = *t++));
|
|
|
560f4e |
*s = u;
|
|
|
560f4e |
- *u = '\0';
|
|
|
560f4e |
+ if (n > 0) /* just one null-byte will do, unlike strncpy(3) */
|
|
|
560f4e |
+ *u = '\0';
|
|
|
560f4e |
}
|
|
|
560f4e |
|
|
|
560f4e |
/* Return the number of elements in an array of pointers. *
|
|
|
560f4e |
--
|
|
|
560f4e |
2.14.3
|
|
|
560f4e |
|