diff options
author | Chet Ramey <chet.ramey@case.edu> | 2014-10-05 19:12:20 -0400 |
---|---|---|
committer | Dan Pasanen <dan.pasanen@gmail.com> | 2014-10-06 07:11:51 -0500 |
commit | 80b4d71117c25c8da61f7fd04802ca35462e79e6 (patch) | |
tree | d2b97fa6b0a9caab66ef86392df731c5a1baef15 /builtins/evalstring.c | |
parent | a417a51c2855f8cd538532903fbcacd234589845 (diff) | |
download | android_external_bash-80b4d71117c25c8da61f7fd04802ca35462e79e6.tar.gz android_external_bash-80b4d71117c25c8da61f7fd04802ca35462e79e6.tar.bz2 android_external_bash-80b4d71117c25c8da61f7fd04802ca35462e79e6.zip |
Bash-4.3 patch 30
Diffstat (limited to 'builtins/evalstring.c')
-rw-r--r-- | builtins/evalstring.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/builtins/evalstring.c b/builtins/evalstring.c index 91b22fe..488051c 100644 --- a/builtins/evalstring.c +++ b/builtins/evalstring.c @@ -308,12 +308,25 @@ parse_and_execute (string, from_file, flags) { struct fd_bitmap *bitmap; - if ((flags & SEVAL_FUNCDEF) && command->type != cm_function_def) + if (flags & SEVAL_FUNCDEF) { - internal_warning ("%s: ignoring function definition attempt", from_file); - should_jump_to_top_level = 0; - last_result = last_command_exit_value = EX_BADUSAGE; - break; + char *x; + + /* If the command parses to something other than a straight + function definition, or if we have not consumed the entire + string, or if the parser has transformed the function + name (as parsing will if it begins or ends with shell + whitespace, for example), reject the attempt */ + if (command->type != cm_function_def || + ((x = parser_remaining_input ()) && *x) || + (STREQ (from_file, command->value.Function_def->name->word) == 0)) + { + internal_warning (_("%s: ignoring function definition attempt"), from_file); + should_jump_to_top_level = 0; + last_result = last_command_exit_value = EX_BADUSAGE; + reset_parser (); + break; + } } bitmap = new_fd_bitmap (FD_BITMAP_SIZE); @@ -378,7 +391,10 @@ parse_and_execute (string, from_file, flags) discard_unwind_frame ("pe_dispose"); if (flags & SEVAL_ONECMD) - break; + { + reset_parser (); + break; + } } } else |