7 Bug-Reported-by: Stephane Chazelas <stephane.chazelas@gmail.com>
13 Under certain circumstances, bash will execute user code while processing the
14 environment for exported function definitions.
16 Patch (apply with `patch -p0'):
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
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 */
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
34 struct fd_bitmap *bitmap;
36 + if ((flags & SEVAL_FUNCDEF) && command->type != cm_function_def)
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;
44 bitmap = new_fd_bitmap (FD_BITMAP_SIZE);
45 begin_unwind_frame ("pe_dispose");
49 dispose_fd_bitmap (bitmap);
50 discard_unwind_frame ("pe_dispose");
52 + if (flags & SEVAL_ONECMD)
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
60 strcpy (temp_string + char_index + 1, string);
62 ! if (posixly_correct == 0 || legal_identifier (name))
63 ! parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST);
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';
70 if (temp_var = find_function (name))
72 strcpy (temp_string + char_index + 1, string);
74 ! /* Don't import function names that are invalid identifiers from the
75 ! environment, though we still allow them to be defined as shell
77 ! if (legal_identifier (name))
78 ! parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST|SEVAL_FUNCDEF|SEVAL_ONECMD);
80 if (temp_var = find_function (name))
83 report_error (_("error importing function definition for `%s'"), name);
87 - if (name[char_index - 1] == ')' && name[char_index - 2] == '\0')
88 - name[char_index - 2] = '('; /* ) */
90 #if defined (ARRAY_VARS)
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
98 ! else if (var = find_variable_last_nameref (temp1))
100 temp = nameref_cell (var);
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)
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
113 looks for to find the patch level (for the sccs version string). */
115 ! #define PATCHLEVEL 24
117 #endif /* _PATCHLEVEL_H_ */
119 looks for to find the patch level (for the sccs version string). */
121 ! #define PATCHLEVEL 25
123 #endif /* _PATCHLEVEL_H_ */