rcolebaugh / rpms / bash

Forked from rpms/bash a year ago
Clone

Blame SOURCES/bash-4.2-cve-2014-7169-2.patch

07a490
--- ../bash-4.2-orig/parse.y	2014-09-25 13:07:59.218209276 +0200
07a490
+++ parse.y	2014-09-25 15:26:52.813159810 +0200
07a490
@@ -264,9 +264,21 @@
07a490
 
07a490
 /* Variables to manage the task of reading here documents, because we need to
07a490
    defer the reading until after a complete command has been collected. */
07a490
-static REDIRECT *redir_stack[10];
07a490
+static REDIRECT **redir_stack;
07a490
 int need_here_doc;
07a490
 
07a490
+/* Pushes REDIR onto redir_stack, resizing it as needed. */
07a490
+static void
07a490
+push_redir_stack (REDIRECT *redir)
07a490
+{
07a490
+  /* Guard against oveflow. */
07a490
+  if (need_here_doc + 1 > INT_MAX / sizeof (*redir_stack))
07a490
+    abort ();
07a490
+  redir_stack = xrealloc (redir_stack,
07a490
+			  (need_here_doc + 1) * sizeof (*redir_stack));
07a490
+  redir_stack[need_here_doc++] = redir;
07a490
+}
07a490
+
07a490
 /* Where shell input comes from.  History expansion is performed on each
07a490
    line when the shell is interactive. */
07a490
 static char *shell_input_line = (char *)NULL;
07a490
@@ -519,42 +531,42 @@
07a490
 			  source.dest = 0;
07a490
 			  redir.filename = $2;
07a490
 			  $$ = make_redirection (source, r_reading_until, redir, 0);
07a490
-			  redir_stack[need_here_doc++] = $$;
07a490
+			  push_redir_stack ($$);
07a490
 			}
07a490
 	|	NUMBER LESS_LESS WORD
07a490
 			{
07a490
 			  source.dest = $1;
07a490
 			  redir.filename = $3;
07a490
 			  $$ = make_redirection (source, r_reading_until, redir, 0);
07a490
-			  redir_stack[need_here_doc++] = $$;
07a490
+			  push_redir_stack ($$);
07a490
 			}
07a490
 	|	REDIR_WORD LESS_LESS WORD
07a490
 			{
07a490
 			  source.filename = $1;
07a490
 			  redir.filename = $3;
07a490
 			  $$ = make_redirection (source, r_reading_until, redir, REDIR_VARASSIGN);
07a490
-			  redir_stack[need_here_doc++] = $$;
07a490
+			  push_redir_stack ($$);
07a490
 			}
07a490
 	|	LESS_LESS_MINUS WORD
07a490
 			{
07a490
 			  source.dest = 0;
07a490
 			  redir.filename = $2;
07a490
 			  $$ = make_redirection (source, r_deblank_reading_until, redir, 0);
07a490
-			  redir_stack[need_here_doc++] = $$;
07a490
+			  push_redir_stack ($$);
07a490
 			}
07a490
 	|	NUMBER LESS_LESS_MINUS WORD
07a490
 			{
07a490
 			  source.dest = $1;
07a490
 			  redir.filename = $3;
07a490
 			  $$ = make_redirection (source, r_deblank_reading_until, redir, 0);
07a490
-			  redir_stack[need_here_doc++] = $$;
07a490
+			  push_redir_stack ($$);
07a490
 			}
07a490
 	|	REDIR_WORD  LESS_LESS_MINUS WORD
07a490
 			{
07a490
 			  source.filename = $1;
07a490
 			  redir.filename = $3;
07a490
 			  $$ = make_redirection (source, r_deblank_reading_until, redir, REDIR_VARASSIGN);
07a490
-			  redir_stack[need_here_doc++] = $$;
07a490
+			  push_redir_stack ($$);
07a490
 			}
07a490
 	|	LESS_LESS_LESS WORD
07a490
 			{
07a490
@@ -4757,7 +4769,7 @@
07a490
     case CASE:
07a490
     case SELECT:
07a490
     case FOR:
07a490
-      if (word_top < MAX_CASE_NEST)
07a490
+      if (word_top + 1 < MAX_CASE_NEST)
07a490
 	word_top++;
07a490
       word_lineno[word_top] = line_number;
07a490
       break;