Blame SOURCES/bash-4.3-cve-2016-0634.patch

462fb2
diff --git a/parse.y b/parse.y
462fb2
index 12d6def..d4a93a2 100644
462fb2
--- a/parse.y
462fb2
+++ b/parse.y
462fb2
@@ -5103,7 +5103,7 @@ decode_prompt_string (string)
462fb2
   size_t result_size;
462fb2
   int result_index;
462fb2
   int c, n, i;
462fb2
-  char *temp, octal_string[4];
462fb2
+  char *temp, *t_host, octal_string[4];
462fb2
   struct tm *tm;  
462fb2
   time_t the_time;
462fb2
   char timebuf[128];
462fb2
@@ -5251,7 +5251,11 @@ decode_prompt_string (string)
462fb2
 
462fb2
 	    case 's':
462fb2
 	      temp = base_pathname (shell_name);
462fb2
-	      temp = savestring (temp);
462fb2
+	      /* Try to quote anything the user can set in the file system */
462fb2
+	      if (promptvars || posixly_correct)
462fb2
+		temp = sh_backslash_quote_for_double_quotes (temp);
462fb2
+	      else
462fb2
+		temp = savestring (temp);
462fb2
 	      goto add_string;
462fb2
 
462fb2
 	    case 'v':
462fb2
@@ -5337,9 +5341,17 @@ decode_prompt_string (string)
462fb2
 
462fb2
 	    case 'h':
462fb2
 	    case 'H':
462fb2
-	      temp = savestring (current_host_name);
462fb2
-	      if (c == 'h' && (t = (char *)strchr (temp, '.')))
462fb2
+	      t_host = savestring (current_host_name);
462fb2
+	      if (c == 'h' && (t = (char *)strchr (t_host, '.')))
462fb2
 		*t = '\0';
462fb2
+	      if (promptvars || posixly_correct)
462fb2
+		/* Make sure that expand_prompt_string is called with a
462fb2
+		   second argument of Q_DOUBLE_QUOTES if we use this
462fb2
+		   function here. */
462fb2
+		temp = sh_backslash_quote_for_double_quotes (t_host);
462fb2
+	      else
462fb2
+		temp = savestring (t_host);
462fb2
+	      free (t_host);
462fb2
 	      goto add_string;
462fb2
 
462fb2
 	    case '#':
462fb2
diff --git a/y.tab.c b/y.tab.c
462fb2
index 23b88bc..1c0f5a1 100644
462fb2
--- a/y.tab.c
462fb2
+++ b/y.tab.c
462fb2
@@ -7368,7 +7368,7 @@ decode_prompt_string (string)
462fb2
   size_t result_size;
462fb2
   int result_index;
462fb2
   int c, n, i;
462fb2
-  char *temp, octal_string[4];
462fb2
+  char *temp, *t_host, octal_string[4];
462fb2
   struct tm *tm;  
462fb2
   time_t the_time;
462fb2
   char timebuf[128];
462fb2
@@ -7513,7 +7513,11 @@ decode_prompt_string (string)
462fb2
 
462fb2
 	    case 's':
462fb2
 	      temp = base_pathname (shell_name);
462fb2
-	      temp = savestring (temp);
462fb2
+	      /* Try to quote anything the user can set in the file system */
462fb2
+	      if (promptvars || posixly_correct)
462fb2
+		temp = sh_backslash_quote_for_double_quotes (temp);
462fb2
+	      else
462fb2
+		temp = savestring (temp);
462fb2
 	      goto add_string;
462fb2
 
462fb2
 	    case 'v':
462fb2
@@ -7599,9 +7603,17 @@ decode_prompt_string (string)
462fb2
 
462fb2
 	    case 'h':
462fb2
 	    case 'H':
462fb2
-	      temp = savestring (current_host_name);
462fb2
-	      if (c == 'h' && (t = (char *)strchr (temp, '.')))
462fb2
+	      t_host = savestring (current_host_name);
462fb2
+	      if (c == 'h' && (t = (char *)strchr (t_host, '.')))
462fb2
 		*t = '\0';
462fb2
+	      if (promptvars || posixly_correct)
462fb2
+		/* Make sure that expand_prompt_string is called with a
462fb2
+		   second argument of Q_DOUBLE_QUOTES if we use this
462fb2
+		   function here. */
462fb2
+		temp = sh_backslash_quote_for_double_quotes (t_host);
462fb2
+	      else
462fb2
+		temp = savestring (t_host);
462fb2
+	      free (t_host);
462fb2
 	      goto add_string;
462fb2
 
462fb2
 	    case '#':
462fb2
-- 
462fb2
2.9.3
462fb2