about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2014-12-18 19:36:03 +0000
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2014-12-18 19:36:03 +0000
commitf3cb9a77543125d4b478f43e068d2a8272d69a0e (patch)
treea276b0072fd5bbe76aae122bc698b7680b66df0d
parente9a640802dd475395a3b12c9924a9d8ecda65226 (diff)
downloadzsh-f3cb9a77543125d4b478f43e068d2a8272d69a0e.tar.gz
zsh-f3cb9a77543125d4b478f43e068d2a8272d69a0e.tar.xz
zsh-f3cb9a77543125d4b478f43e068d2a8272d69a0e.zip
34006: unmetafy anything put into the environment
-rw-r--r--ChangeLog3
-rw-r--r--Src/params.c12
2 files changed, 14 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 4529bfc48..ff802b874 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2014-12-18  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
+	* 34006: Src/params.c: unmetafy anything put into the
+	environment.
+
 	* Lokesh Mandvekar: 33999: Completion/Linux/Command/_docker:
 	remove completion as the version supplied with docker is
 	authoritative.
diff --git a/Src/params.c b/Src/params.c
index 79088d162..b87598a02 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -4357,7 +4357,18 @@ arrfixenv(char *s, char **t)
 int
 zputenv(char *str)
 {
+    char *ptr;
     DPUTS(!str, "Attempt to put null string into environment.");
+    /*
+     * The environment uses NULL-terminated strings, so just
+     * unmetafy and ignore the length.
+     */
+    for (ptr = str; *ptr && *ptr != Meta; ptr++)
+	;
+    if (*ptr == Meta) {
+	str = dupstring(str);
+	unmetafy(str, NULL);
+    }
 #ifdef USE_SET_UNSET_ENV
     /*
      * If we are using unsetenv() to remove values from the
@@ -4366,7 +4377,6 @@ zputenv(char *str)
      * Unfortunately this is a slightly different interface
      * from what zputenv() assumes.
      */
-    char *ptr;
     int ret;
 
     for (ptr = str; *ptr && *ptr != '='; ptr++)