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

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