components/bash/patches/funcdef-import-4.1-CVE-2014-6271.patch
author Stefan Teleman <stefan.teleman@oracle.com>
Wed, 24 Sep 2014 13:04:10 -0700
branchs11-update
changeset 3330 bed1d2a86c86
permissions -rw-r--r--
19678459 problem in UTILITY/BASH
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3330
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     1
# Patch is from the bash project.
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     2
# It is currently embargo'ed (as of 2014-02-23).
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     3
# It will become an official bash patch once the embargo is lifted.
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     4
*** ../bash-4.1.11/builtins/common.h	2009-12-22 16:30:42.000000000 -0500
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     5
--- builtins/common.h	2014-09-16 19:27:38.000000000 -0400
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     6
***************
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     7
*** 36,39 ****
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     8
--- 36,41 ----
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     9
  
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    10
  /* Flags for describe_command, shared between type.def and command.def */
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    11
+ #define SEVAL_FUNCDEF	0x080		/* only allow function definitions */
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    12
+ #define SEVAL_ONECMD	0x100		/* only allow a single command */
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    13
  #define CDESC_ALL		0x001	/* type -a */
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    14
  #define CDESC_SHORTDESC		0x002	/* command -V */
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    15
*** ../bash-4.1.11/builtins/evalstring.c	2009-10-17 21:18:50.000000000 -0400
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    16
--- builtins/evalstring.c	2014-09-16 19:27:38.000000000 -0400
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    17
***************
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    18
*** 262,265 ****
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    19
--- 262,273 ----
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    20
  	      struct fd_bitmap *bitmap;
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    21
  
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    22
+ 	      if ((flags & SEVAL_FUNCDEF) && command->type != cm_function_def)
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    23
+ 		{
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    24
+ 		  internal_warning ("%s: ignoring function definition attempt", from_file);
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    25
+ 		  should_jump_to_top_level = 0;
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    26
+ 		  last_result = last_command_exit_value = EX_BADUSAGE;
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    27
+ 		  break;
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    28
+ 		}
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    29
+ 
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    30
  	      bitmap = new_fd_bitmap (FD_BITMAP_SIZE);
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    31
  	      begin_unwind_frame ("pe_dispose");
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    32
***************
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    33
*** 322,325 ****
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    34
--- 330,336 ----
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    35
  	      dispose_fd_bitmap (bitmap);
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    36
  	      discard_unwind_frame ("pe_dispose");
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    37
+ 
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    38
+ 	      if (flags & SEVAL_ONECMD)
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    39
+ 		break;
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    40
  	    }
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    41
  	}
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    42
*** ../bash-4.1.11/variables.c	2010-03-26 12:15:39.000000000 -0400
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    43
--- variables.c	2014-09-16 19:27:38.000000000 -0400
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    44
***************
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    45
*** 348,357 ****
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    46
  	  strcpy (temp_string + char_index + 1, string);
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    47
  
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    48
! 	  parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST);
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    49
! 
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    50
! 	  /* Ancient backwards compatibility.  Old versions of bash exported
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    51
! 	     functions like name()=() {...} */
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    52
! 	  if (name[char_index - 1] == ')' && name[char_index - 2] == '(')
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    53
! 	    name[char_index - 2] = '\0';
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    54
  
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    55
  	  if (temp_var = find_function (name))
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    56
--- 348,355 ----
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    57
  	  strcpy (temp_string + char_index + 1, string);
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    58
  
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    59
! 	  /* Don't import function names that are invalid identifiers from the
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    60
! 	     environment. */
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    61
! 	  if (legal_identifier (name))
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    62
! 	    parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST|SEVAL_FUNCDEF|SEVAL_ONECMD);
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    63
  
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    64
  	  if (temp_var = find_function (name))
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    65
***************
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    66
*** 362,369 ****
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    67
  	  else
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    68
  	    report_error (_("error importing function definition for `%s'"), name);
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    69
- 
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    70
- 	  /* ( */
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    71
- 	  if (name[char_index - 1] == ')' && name[char_index - 2] == '\0')
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    72
- 	    name[char_index - 2] = '(';		/* ) */
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    73
  	}
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    74
  #if defined (ARRAY_VARS)
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    75
--- 360,363 ----
bed1d2a86c86 19678459 problem in UTILITY/BASH
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    76