[c5c522c] | 1 | BASH PATCH REPORT |
---|
| 2 | ================= |
---|
| 3 | |
---|
| 4 | Bash-Release: 4.3 |
---|
| 5 | Patch-ID: bash43-025 |
---|
| 6 | |
---|
| 7 | Bug-Reported-by: Stephane Chazelas <stephane.chazelas@gmail.com> |
---|
| 8 | Bug-Reference-ID: |
---|
| 9 | Bug-Reference-URL: |
---|
| 10 | |
---|
| 11 | Bug-Description: |
---|
| 12 | |
---|
| 13 | Under certain circumstances, bash will execute user code while processing the |
---|
| 14 | environment for exported function definitions. |
---|
| 15 | |
---|
| 16 | Patch (apply with `patch -p0'): |
---|
| 17 | |
---|
| 18 | *** ../bash-4.3-patched/builtins/common.h 2013-07-08 16:54:47.000000000 -0400 |
---|
| 19 | --- builtins/common.h 2014-09-12 14:25:47.000000000 -0400 |
---|
| 20 | *************** |
---|
| 21 | *** 34,37 **** |
---|
| 22 | --- 49,54 ---- |
---|
| 23 | #define SEVAL_PARSEONLY 0x020 |
---|
| 24 | #define SEVAL_NOLONGJMP 0x040 |
---|
| 25 | + #define SEVAL_FUNCDEF 0x080 /* only allow function definitions */ |
---|
| 26 | + #define SEVAL_ONECMD 0x100 /* only allow a single command */ |
---|
| 27 | |
---|
| 28 | /* Flags for describe_command, shared between type.def and command.def */ |
---|
| 29 | *** ../bash-4.3-patched/builtins/evalstring.c 2014-02-11 09:42:10.000000000 -0500 |
---|
| 30 | --- builtins/evalstring.c 2014-09-14 14:15:13.000000000 -0400 |
---|
| 31 | *************** |
---|
| 32 | *** 309,312 **** |
---|
| 33 | --- 313,324 ---- |
---|
| 34 | struct fd_bitmap *bitmap; |
---|
| 35 | |
---|
| 36 | + if ((flags & SEVAL_FUNCDEF) && command->type != cm_function_def) |
---|
| 37 | + { |
---|
| 38 | + internal_warning ("%s: ignoring function definition attempt", from_file); |
---|
| 39 | + should_jump_to_top_level = 0; |
---|
| 40 | + last_result = last_command_exit_value = EX_BADUSAGE; |
---|
| 41 | + break; |
---|
| 42 | + } |
---|
| 43 | + |
---|
| 44 | bitmap = new_fd_bitmap (FD_BITMAP_SIZE); |
---|
| 45 | begin_unwind_frame ("pe_dispose"); |
---|
| 46 | *************** |
---|
| 47 | *** 369,372 **** |
---|
| 48 | --- 381,387 ---- |
---|
| 49 | dispose_fd_bitmap (bitmap); |
---|
| 50 | discard_unwind_frame ("pe_dispose"); |
---|
| 51 | + |
---|
| 52 | + if (flags & SEVAL_ONECMD) |
---|
| 53 | + break; |
---|
| 54 | } |
---|
| 55 | } |
---|
| 56 | *** ../bash-4.3-patched/variables.c 2014-05-15 08:26:50.000000000 -0400 |
---|
| 57 | --- variables.c 2014-09-14 14:23:35.000000000 -0400 |
---|
| 58 | *************** |
---|
| 59 | *** 359,369 **** |
---|
| 60 | strcpy (temp_string + char_index + 1, string); |
---|
| 61 | |
---|
| 62 | ! if (posixly_correct == 0 || legal_identifier (name)) |
---|
| 63 | ! parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST); |
---|
| 64 | ! |
---|
| 65 | ! /* Ancient backwards compatibility. Old versions of bash exported |
---|
| 66 | ! functions like name()=() {...} */ |
---|
| 67 | ! if (name[char_index - 1] == ')' && name[char_index - 2] == '(') |
---|
| 68 | ! name[char_index - 2] = '\0'; |
---|
| 69 | |
---|
| 70 | if (temp_var = find_function (name)) |
---|
| 71 | --- 364,372 ---- |
---|
| 72 | strcpy (temp_string + char_index + 1, string); |
---|
| 73 | |
---|
| 74 | ! /* Don't import function names that are invalid identifiers from the |
---|
| 75 | ! environment, though we still allow them to be defined as shell |
---|
| 76 | ! variables. */ |
---|
| 77 | ! if (legal_identifier (name)) |
---|
| 78 | ! parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST|SEVAL_FUNCDEF|SEVAL_ONECMD); |
---|
| 79 | |
---|
| 80 | if (temp_var = find_function (name)) |
---|
| 81 | *************** |
---|
| 82 | *** 382,389 **** |
---|
| 83 | report_error (_("error importing function definition for `%s'"), name); |
---|
| 84 | } |
---|
| 85 | - |
---|
| 86 | - /* ( */ |
---|
| 87 | - if (name[char_index - 1] == ')' && name[char_index - 2] == '\0') |
---|
| 88 | - name[char_index - 2] = '('; /* ) */ |
---|
| 89 | } |
---|
| 90 | #if defined (ARRAY_VARS) |
---|
| 91 | --- 385,388 ---- |
---|
| 92 | *** ../bash-4.3-patched/subst.c 2014-08-11 11:16:35.000000000 -0400 |
---|
| 93 | --- subst.c 2014-09-12 15:31:04.000000000 -0400 |
---|
| 94 | *************** |
---|
| 95 | *** 8048,8052 **** |
---|
| 96 | goto return0; |
---|
| 97 | } |
---|
| 98 | ! else if (var = find_variable_last_nameref (temp1)) |
---|
| 99 | { |
---|
| 100 | temp = nameref_cell (var); |
---|
| 101 | --- 8118,8124 ---- |
---|
| 102 | goto return0; |
---|
| 103 | } |
---|
| 104 | ! else if (var && (invisible_p (var) || var_isset (var) == 0)) |
---|
| 105 | ! temp = (char *)NULL; |
---|
| 106 | ! else if ((var = find_variable_last_nameref (temp1)) && var_isset (var) && invisible_p (var) == 0) |
---|
| 107 | { |
---|
| 108 | temp = nameref_cell (var); |
---|
| 109 | *** ../bash-4.3/patchlevel.h 2012-12-29 10:47:57.000000000 -0500 |
---|
| 110 | --- patchlevel.h 2014-03-20 20:01:28.000000000 -0400 |
---|
| 111 | *************** |
---|
| 112 | *** 26,30 **** |
---|
| 113 | looks for to find the patch level (for the sccs version string). */ |
---|
| 114 | |
---|
| 115 | ! #define PATCHLEVEL 24 |
---|
| 116 | |
---|
| 117 | #endif /* _PATCHLEVEL_H_ */ |
---|
| 118 | --- 26,30 ---- |
---|
| 119 | looks for to find the patch level (for the sccs version string). */ |
---|
| 120 | |
---|
| 121 | ! #define PATCHLEVEL 25 |
---|
| 122 | |
---|
| 123 | #endif /* _PATCHLEVEL_H_ */ |
---|