Blame SOURCES/zsh-5.0.2-ksh-syntax-check.patch

c6dbd9
From e4761e2cc86db577127ed7f6884bd42363883a16 Mon Sep 17 00:00:00 2001
c6dbd9
From: Peter Stephenson <pws@users.sourceforge.net>
c6dbd9
Date: Tue, 22 Jan 2013 16:28:58 +0000
c6dbd9
Subject: [PATCH 1/3] 30993: fix parameter modifier crash with :wq on empty
c6dbd9
 string
c6dbd9
c6dbd9
Upstream-commit: 44757a653cb547ae7b556e8c92629d296d3c1f12
c6dbd9
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
c6dbd9
---
c6dbd9
 Src/subst.c            | 10 +++++++++-
c6dbd9
 Test/D04parameter.ztst |  7 +++++++
c6dbd9
 2 files changed, 16 insertions(+), 1 deletion(-)
c6dbd9
c6dbd9
diff --git a/Src/subst.c b/Src/subst.c
c6dbd9
index 974a845..a4df256 100644
c6dbd9
--- a/Src/subst.c
c6dbd9
+++ b/Src/subst.c
c6dbd9
@@ -3707,6 +3707,11 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
c6dbd9
 	char *y;
c6dbd9
 
c6dbd9
 	x = val;
c6dbd9
+	if (!x) {
c6dbd9
+	    /* Shouldn't have got here with a NULL string. */
c6dbd9
+	    DPUTS(1, "value is NULL in paramsubst");
c6dbd9
+	    return NULL;
c6dbd9
+	}
c6dbd9
 	if (prenum || postnum)
c6dbd9
 	    x = dopadding(x, prenum, postnum, preone, postone,
c6dbd9
 			  premul, postmul
c6dbd9
@@ -4021,7 +4026,10 @@ modify(char **str, char **ptr)
c6dbd9
 		    all = tmp;
c6dbd9
 		    t = e;
c6dbd9
 		}
c6dbd9
-		*str = all;
c6dbd9
+		if (!all)
c6dbd9
+		    *str = dupstring("");
c6dbd9
+		else
c6dbd9
+		    *str = all;
c6dbd9
 
c6dbd9
 	    } else {
c6dbd9
 		switch (c) {
c6dbd9
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
c6dbd9
index 01f8412..bea9459 100644
c6dbd9
--- a/Test/D04parameter.ztst
c6dbd9
+++ b/Test/D04parameter.ztst
c6dbd9
@@ -1544,3 +1544,10 @@
c6dbd9
 0:Regression test for shwordsplit with null or unset IFS and quoted array
c6dbd9
 >abc
c6dbd9
 >a b c
c6dbd9
+
c6dbd9
+   foo=
c6dbd9
+   print ${foo:wq}
c6dbd9
+   print ${:wq}
c6dbd9
+0:Empty parameter shouldn't cause modifiers to crash the shell
c6dbd9
+>
c6dbd9
+>
c6dbd9
-- 
c6dbd9
2.5.2
c6dbd9
c6dbd9
704a93
From 3427fe59c2d76ddbf4b23908c6ae5272734c7c8b Mon Sep 17 00:00:00 2001
704a93
From: "Barton E. Schaefer" <schaefer@zsh.org>
704a93
Date: Wed, 20 May 2015 10:14:04 -0700
c6dbd9
Subject: [PATCH 2/3] 35231: make mkevnstr() safe for NULL value
704a93
704a93
Upstream-commit: af957f2ed6287f66953742fbca69188cecb98fbf
704a93
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
704a93
---
704a93
 Src/params.c | 14 +++++++++-----
704a93
 1 file changed, 9 insertions(+), 5 deletions(-)
704a93
704a93
diff --git a/Src/params.c b/Src/params.c
704a93
index 61edc5d..d0ce0a9 100644
704a93
--- a/Src/params.c
704a93
+++ b/Src/params.c
704a93
@@ -4488,17 +4488,21 @@ addenv(Param pm, char *value)
704a93
 static char *
704a93
 mkenvstr(char *name, char *value, int flags)
704a93
 {
704a93
-    char *str, *s;
704a93
-    int len_name, len_value;
704a93
+    char *str, *s = value;
704a93
+    int len_name, len_value = 0;
704a93
 
704a93
     len_name = strlen(name);
704a93
-    for (len_value = 0, s = value;
704a93
-	 *s && (*s++ != Meta || *s++ != 32); len_value++);
704a93
+    if (s)
704a93
+	while (*s && (*s++ != Meta || *s++ != 32))
704a93
+	    len_value++;
704a93
     s = str = (char *) zalloc(len_name + len_value + 2);
704a93
     strcpy(s, name);
704a93
     s += len_name;
704a93
     *s = '=';
704a93
-    copyenvstr(s, value, flags);
704a93
+    if (value)
704a93
+	copyenvstr(s, value, flags);
704a93
+    else
704a93
+	*++s = '\0';
704a93
     return str;
704a93
 }
704a93
 
704a93
-- 
704a93
2.4.1
704a93
c6dbd9
c6dbd9
From e92e9cbe55c7611e6eef59bf671de9bc95225d56 Mon Sep 17 00:00:00 2001
c6dbd9
From: Peter Stephenson <pws@zsh.org>
c6dbd9
Date: Tue, 6 Oct 2015 09:28:07 +0100
c6dbd9
Subject: [PATCH 3/3] 36780: Fix crash in ksh mode with -n and $HOME.
c6dbd9
c6dbd9
If home variable is NULL ensure HOME is unset.
c6dbd9
c6dbd9
Upstream-commit: 83a175795a444e8169fcb592a110d4d15a09b907
c6dbd9
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
c6dbd9
---
c6dbd9
 Src/params.c | 13 +++++++------
c6dbd9
 1 file changed, 7 insertions(+), 6 deletions(-)
c6dbd9
c6dbd9
diff --git a/Src/params.c b/Src/params.c
c6dbd9
index e9e6545..babf6f2 100644
c6dbd9
--- a/Src/params.c
c6dbd9
+++ b/Src/params.c
c6dbd9
@@ -755,17 +755,18 @@ createparamtable(void)
c6dbd9
 #endif
c6dbd9
     opts[ALLEXPORT] = oae;
c6dbd9
 
c6dbd9
+    /*
c6dbd9
+     * For native emulation we always set the variable home
c6dbd9
+     * (see setupvals()).
c6dbd9
+     */
c6dbd9
+    pm = (Param) paramtab->getnode(paramtab, "HOME");
c6dbd9
     if (EMULATION(EMULATE_ZSH))
c6dbd9
     {
c6dbd9
-	/*
c6dbd9
-	 * For native emulation we always set the variable home
c6dbd9
-	 * (see setupvals()).
c6dbd9
-	 */
c6dbd9
-	pm = (Param) paramtab->getnode(paramtab, "HOME");
c6dbd9
 	pm->node.flags &= ~PM_UNSET;
c6dbd9
 	if (!(pm->node.flags & PM_EXPORTED))
c6dbd9
 	    addenv(pm, home);
c6dbd9
-    }
c6dbd9
+    } else if (!home)
c6dbd9
+	pm->node.flags |= PM_UNSET;
c6dbd9
     pm = (Param) paramtab->getnode(paramtab, "LOGNAME");
c6dbd9
     if (!(pm->node.flags & PM_EXPORTED))
c6dbd9
 	addenv(pm, pm->u.str);
c6dbd9
-- 
c6dbd9
2.5.2
c6dbd9