From 2b7361d5c124f05181fb575de4e283391c011a1e Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Fri, 18 Sep 2015 08:59:01 -0400 Subject: [PATCH] commit bash-20150911 snapshot --- CHANGES | 117 ++++++++++++++++++++++++++++++++++++++++++++ CHANGES-4.4 | 117 ++++++++++++++++++++++++++++++++++++++++++++ CWRU/CWRU.chlog | 85 ++++++++++++++++++-------------- NEWS | 11 +++++ NEWS-4.4 | 11 +++++ lib/readline/kill.c | 2 +- shell.c | 15 ++++-- 7 files changed, 316 insertions(+), 42 deletions(-) diff --git a/CHANGES b/CHANGES index c59db8ca..4bc2ac54 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,123 @@ This document details the changes between this version, bash-4.4-alpha, and the previous version, bash-4.3-release. +1. Change to Bash + +a. Fixed two bugs that caused out-of-bounds reads when skipping over assignment + statements while finding the word on which to perform programmable + completion. + +b. Fixed a memory leak in programmable completion. + +c. Fixed a bug that could cause the shell to crash when interrupting the + wait builtin. + +d. Fixed a bug that caused ${!vvv@} to be interpreted as introducing the new + `@' operator. + +e. Fixed a bug that caused the && and || operators to be incorrectly optimized. + +f. The shell now undoes redirections before exiting the shell when the `-e' + option is enabled, and a shell function fails. + +g. History expansion now skips over the history expansion character in command + and process substitution. + +h. Fixed a bug that caused stray '\001' characters to be added to the output + of `declare -p'. + +i. Fixed a memory leak when processing declare commands that perform compound + array assignments. + +j. Fixed a bug that could cause the shell to crash when reading input from a + file and the limit on open file descriptors is high. + +k. Fixed a bug that caused the ERR and RETURN traps to be unset if they were + set in a shell function but unset previously. + +l. Fixed a bug that caused several signals to be ignored if `exec' failed in + an interactive shell. + +m. A posix-mode non-interactive shell now considers a parameter expansion error + to be a fatal error. + +n. The `time' command now prints timing statistics for failed commands when + the -e option is enabled. + +o. Fixed a bug that caused the shell to crash when attempting to indirectly + expand a shell variable with an invalid name. + +p. Fixed a bug that caused the shell to crash when running a trap containing + a process substitution. + +q. Bash now prints the keyword `function' before a function with the same name + as a reserved word when using `declare -f' to avoid parse errors when + reusing the output as input. + +r. Fixed a bug that caused the shell to crash when using declare -g to attempt + to redefine an existing global indexed array variable as an associative + array. + +s. Fixed a memory leak that occurred when interrupting brace expansions + generating a sequence. + +t. Fixed a bug that resulted in alias expansion in redirections. + +u. The `declare -a' and `declare -A' commands now print fewer warnings when + attempting to create and initialize an array at the same time, but + relying on word expansions to construct the compound assignment. + +v. The `help' builtin now behaves better in locales where each wide + character occupies more than one display column. + +w. The `read' builtin no longer has a possible race condition when a timeout + occurs. + +x. Fixed several expansion problems encountered when IFS="'". + +y. Fixed a problem with the expansion of $'\c?'. + +z. Bash no longer splits the expansion of here-strings, as the documentation + has always said. + +2. Changes to Readline + +a. Colored completion prefixes are now displayed using a different color, less + likely to collide with files. + +b. Fixed a bug that caused vi-mode character search to misbehave when + running in callback mode. + +c. Fixed a bug that caused output to be delayed when input is coming from a + macro in vi-mode. + +d. Fixed a bug that caused the vi-mode `.' command to misbehave when redoing + a multi-key key sequence via a macro. + +e. Fixed a bug that caused problems with applications that supply their own + input function when performing completion. + +f. When read returns -1/EIO when attempting to read a key, return an error + instead of line termination back to the caller. + +3. New Features in Bash + +a. `make install' now installs the example loadable builtins and a set of + bash headers to use when developing new loadable builtins. + +b. `enable -f' now attempts to call functions named BUILTIN_builtin_load when + loading BUILTIN, and BUILTIN_builtin_unload when deleting it. This allows + loadable builtins to run initialization and cleanup code. + +c. There is a new BASH_LOADABLES_PATH variable containing a list of directories + where the `enable -f' command looks for shared objects containing loadable + builtins. + +4. New Features in Readline +------------------------------------------------------------------------------ +This document details the changes between this version, bash-4.4-alpha, and +the previous version, bash-4.3-release. + 1. Changes to Bash a. A bug that caused pipelines to be corrupted while running the DEBUG trap diff --git a/CHANGES-4.4 b/CHANGES-4.4 index b0477a3b..d1f39b57 100644 --- a/CHANGES-4.4 +++ b/CHANGES-4.4 @@ -1,6 +1,123 @@ This document details the changes between this version, bash-4.4-alpha, and the previous version, bash-4.3-release. +1. Change to Bash + +a. Fixed two bugs that caused out-of-bounds reads when skipping over assignment + statements while finding the word on which to perform programmable + completion. + +b. Fixed a memory leak in programmable completion. + +c. Fixed a bug that could cause the shell to crash when interrupting the + wait builtin. + +d. Fixed a bug that caused ${!vvv@} to be interpreted as introducing the new + `@' operator. + +e. Fixed a bug that caused the && and || operators to be incorrectly optimized. + +f. The shell now undoes redirections before exiting the shell when the `-e' + option is enabled, and a shell function fails. + +g. History expansion now skips over the history expansion character in command + and process substitution. + +h. Fixed a bug that caused stray '\001' characters to be added to the output + of `declare -p'. + +i. Fixed a memory leak when processing declare commands that perform compound + array assignments. + +j. Fixed a bug that could cause the shell to crash when reading input from a + file and the limit on open file descriptors is high. + +k. Fixed a bug that caused the ERR and RETURN traps to be unset if they were + set in a shell function but unset previously. + +l. Fixed a bug that caused several signals to be ignored if `exec' failed in + an interactive shell. + +m. A posix-mode non-interactive shell now considers a parameter expansion error + to be a fatal error. + +n. The `time' command now prints timing statistics for failed commands when + the -e option is enabled. + +o. Fixed a bug that caused the shell to crash when attempting to indirectly + expand a shell variable with an invalid name. + +p. Fixed a bug that caused the shell to crash when running a trap containing + a process substitution. + +q. Bash now prints the keyword `function' before a function with the same name + as a reserved word when using `declare -f' to avoid parse errors when + reusing the output as input. + +r. Fixed a bug that caused the shell to crash when using declare -g to attempt + to redefine an existing global indexed array variable as an associative + array. + +s. Fixed a memory leak that occurred when interrupting brace expansions + generating a sequence. + +t. Fixed a bug that resulted in alias expansion in redirections. + +u. The `declare -a' and `declare -A' commands now print fewer warnings when + attempting to create and initialize an array at the same time, but + relying on word expansions to construct the compound assignment. + +v. The `help' builtin now behaves better in locales where each wide + character occupies more than one display column. + +w. The `read' builtin no longer has a possible race condition when a timeout + occurs. + +x. Fixed several expansion problems encountered when IFS="'". + +y. Fixed a problem with the expansion of $'\c?'. + +z. Bash no longer splits the expansion of here-strings, as the documentation + has always said. + +2. Changes to Readline + +a. Colored completion prefixes are now displayed using a different color, less + likely to collide with files. + +b. Fixed a bug that caused vi-mode character search to misbehave when + running in callback mode. + +c. Fixed a bug that caused output to be delayed when input is coming from a + macro in vi-mode. + +d. Fixed a bug that caused the vi-mode `.' command to misbehave when redoing + a multi-key key sequence via a macro. + +e. Fixed a bug that caused problems with applications that supply their own + input function when performing completion. + +f. When read returns -1/EIO when attempting to read a key, return an error + instead of line termination back to the caller. + +3. New Features in Bash + +a. `make install' now installs the example loadable builtins and a set of + bash headers to use when developing new loadable builtins. + +b. `enable -f' now attempts to call functions named BUILTIN_builtin_load when + loading BUILTIN, and BUILTIN_builtin_unload when deleting it. This allows + loadable builtins to run initialization and cleanup code. + +c. There is a new BASH_LOADABLES_PATH variable containing a list of directories + where the `enable -f' command looks for shared objects containing loadable + builtins. + +4. New Features in Readline +------------------------------------------------------------------------------ +This document details the changes between this version, bash-4.4-alpha, and +the previous version, bash-4.3-release. + 1. Changes to Bash a. A bug that caused pipelines to be corrupted while running the DEBUG trap diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 3b314444..f021a5fd 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -9169,8 +9169,8 @@ doc/{bash.1,bashref.texi} 7/27 ---- examples/loadables/Makefile.in - - add variables and targets to support `make install'; installs supported - builtins in $(libdir)/bash + - add variables and targets to support `make install'; installs + supported builtins in $(libdir)/bash 7/28 ---- @@ -9186,9 +9186,9 @@ trap.[ch] trapped; similar to maybe_set_debug_trap back from 4/10 lib/malloc/malloc.c - - internal_free: make sure `ubytes' is initialized if MALLOC_WATCH is defined - and we'll be passing it to _malloc_ckwatch. Report from Flavio Medeiros - + - internal_free: make sure `ubytes' is initialized if MALLOC_WATCH is + defined and we'll be passing it to _malloc_ckwatch. Report from + Flavio Medeiros execute_cmd.c - execute_function: use maybe_set_error_trap in the same way as @@ -9198,9 +9198,9 @@ execute_cmd.c 7/29 ---- jobs.c - - wait_for: no longer need to call job_signal_status when checking whether - a comsub shell reaped a child that died due to SIGINT; code now uses - child_caught_sigint + - wait_for: no longer need to call job_signal_status when checking + whether a comsub shell reaped a child that died due to SIGINT; code + now uses child_caught_sigint 7/30 ---- @@ -9225,13 +9225,13 @@ general.h builtins/enable.def - dyn_load_builtin: attempt to execute a function named BUILTIN_builtin_load, - where BUILTIN is the name of the command being loaded. If that function - returns 0, the load fails + where BUILTIN is the name of the command being loaded. If that + function returns 0, the load fails - dyn_unload_builtin: attempt to execute a function named BUILTIN_builtin_unload, where BUILTIN is the name of the command being unloaded. It offers a - dynamic builtin a way to clean up after itself. Inspired by suggestion - from Piotr Grzybowski in response to a bug report - from isabella parakiss + dynamic builtin a way to clean up after itself. Inspired by + suggestion from Piotr Grzybowski in response + to a bug report from isabella parakiss 8/6 --- @@ -9265,12 +9265,12 @@ lib/readline/readline.c map passed as an argument. Without this, vi mode doesn't call rl_vi_set_last when it should - _rl_dispatch_subseq: if redoing a vi mode command with `.' - (_rl_vi_redoing != 0) in callback mode and we're indirecting into another - keymap that has shadowed the key corresponding to the command we are - redoing, just call _rl_subseq_result immediately: vi redo doesn't need - to read any additional input, and rl_vi_redo assumes that a single call - to rl_dispatch is sufficient. Fixes bug reported by Carlos Pita - + (_rl_vi_redoing != 0) in callback mode and we're indirecting into + another keymap that has shadowed the key corresponding to the command + we are redoing, just call _rl_subseq_result immediately: vi redo + doesn't need to read any additional input, and rl_vi_redo assumes + that a single call to rl_dispatch is sufficient. Fixes bug reported + by Carlos Pita 8/7 --- @@ -9329,10 +9329,10 @@ bashhist.h 8/11 ---- doc/{bash.1,bashref.texi} - - GROUPS,FUNCNAME: change description to note that assignments are silently - ignored, but do not return an error (which would constitute an assignment - error and cause posix mode shells to abort). Problem pointed out by - Grzegorz Bajson + - GROUPS,FUNCNAME: change description to note that assignments are + silently ignored, but do not return an error (which would constitute + an assignment error and cause posix mode shells to abort). Problem + pointed out by Grzegorz Bajson 8/12 ---- @@ -9349,10 +9349,10 @@ subst.c ---- jobs.c - {save,restore}_pipeline: saved_pipeline now a linked list of pipelines, - new ones allocated in save_pipeline and freed in restore_pipeline. This - allow multiple nested calls to save_pipeline (e.g., in traps and then in - process substitution). Fix for bug reported by isabella parakiss - + new ones allocated in save_pipeline and freed in restore_pipeline. + This allow multiple nested calls to save_pipeline (e.g., in traps + and then in process substitution). Fix for bug reported by isabella + parakiss print_cmd.c - named_function_string: if printing a function with the same name as a @@ -9390,8 +9390,8 @@ configure.ac,Makefile.in,builtins/Makefile.in ---- subst.c - shell_expand_word_list: if make_internal_declare fails, make sure to - propagate that error return back and make the assignment statement fail. - Fixes seg fault reported by Sergey Tselikh + propagate that error return back and make the assignment statement + fail. Fixes seg fault reported by Sergey Tselikh 8/20 ---- @@ -9407,8 +9407,8 @@ braces.c to avoid a memory leak trap.c - - maybe_set_return_trap: set the RETURN trap to string if it's not already - trapped, in the same way as the debug and error traps + - maybe_set_return_trap: set the RETURN trap to string if it's not + already trapped, in the same way as the debug and error traps execute_cmd.c - execute_function: use maybe_set_return_trap to allow functions to set @@ -9470,12 +9470,12 @@ sig.c 8/25 ---- subst.h - - SD_HISTEXP: new flag for skip_to_delim, indicates we are looking for the - history expansion character (special double quote handling) - - skip_to_delim: handle SD_HISTEXP flag, changes double quote handling to - be similar to history library: don't call skip_double_quote, make sure - single quotes aren't special in double quotes, but continue to skip - over $(), ${}, and other similar constructs + - SD_HISTEXP: new flag for skip_to_delim, indicates we are looking for + the history expansion character (special double quote handling) + - skip_to_delim: handle SD_HISTEXP flag, changes double quote handling + to be similar to history library: don't call skip_double_quote, make + sure single quotes aren't special in double quotes, but continue to + skip over $(), ${}, and other similar constructs 8/27 ---- @@ -9559,3 +9559,14 @@ lib/readline/util.c lib/readline/readline.c - HAVE_DECL_AUDIT_USER_TTY: correct #define check + + 9/13 + ---- +shell.c + - read_from_stdin: make sure value set to 1 appropriately if the shell + is reading from standard input, as Posix seems to specify (?) + +lib/readline/kill.c + - _rl_copy_to_kill_ring: don't assume that rl_kill_ring has been + allocated if _rl_last_command_was_kill is non-zero; make sure it's + non-null before indexing into it diff --git a/NEWS b/NEWS index 8cad1839..e9223923 100644 --- a/NEWS +++ b/NEWS @@ -96,6 +96,17 @@ bb. Aliases whose value ends in a shell metacharacter now expand in a way to allow them to be `pasted' to the next token, which can potentially change the meaning of a command (e.g., turning `&' into `&&'). +cc. `make install' now installs the example loadable builtins and a set of + bash headers to use when developing new loadable builtins. + +dd. `enable -f' now attempts to call functions named BUILTIN_builtin_load when + loading BUILTIN, and BUILTIN_builtin_unload when deleting it. This allows + loadable builtins to run initialization and cleanup code. + +ee. There is a new BASH_LOADABLES_PATH variable containing a list of directories + where the `enable -f' command looks for shared objects containing loadable + builtins. + 2. New Features in Readline a. The history truncation code now uses the same error recovery mechansim as diff --git a/NEWS-4.4 b/NEWS-4.4 index a2cd9867..4dab553a 100644 --- a/NEWS-4.4 +++ b/NEWS-4.4 @@ -96,6 +96,17 @@ bb. Aliases whose value ends in a shell metacharacter now expand in a way to allow them to be `pasted' to the next token, which can potentially change the meaning of a command (e.g., turning `&' into `&&'). +cc. `make install' now installs the example loadable builtins and a set of + bash headers to use when developing new loadable builtins. + +dd. `enable -f' now attempts to call functions named BUILTIN_builtin_load when + loading BUILTIN, and BUILTIN_builtin_unload when deleting it. This allows + loadable builtins to run initialization and cleanup code. + +ee. There is a new BASH_LOADABLES_PATH variable containing a list of directories + where the `enable -f' command looks for shared objects containing loadable + builtins. + 2. New Features in Readline a. The history truncation code now uses the same error recovery mechansim as diff --git a/lib/readline/kill.c b/lib/readline/kill.c index 166302cf..7a0708cb 100644 --- a/lib/readline/kill.c +++ b/lib/readline/kill.c @@ -97,7 +97,7 @@ _rl_copy_to_kill_ring (text, append) int slot; /* First, find the slot to work with. */ - if (_rl_last_command_was_kill == 0) + if (_rl_last_command_was_kill == 0 || rl_kill_ring == 0) { /* Get a new slot. */ if (rl_kill_ring == 0) diff --git a/shell.c b/shell.c index 74ec2668..77467f66 100644 --- a/shell.c +++ b/shell.c @@ -712,13 +712,20 @@ main (argc, argv, env) arg_index++; } else if (interactive == 0) - /* In this mode, bash is reading a script from stdin, which is a - pipe or redirected file. */ + { + /* In this mode, bash is reading a script from stdin, which is a + pipe or redirected file. */ #if defined (BUFFERED_INPUT) - default_buffered_input = fileno (stdin); /* == 0 */ + default_buffered_input = fileno (stdin); /* == 0 */ #else - setbuf (default_input, (char *)NULL); + setbuf (default_input, (char *)NULL); #endif /* !BUFFERED_INPUT */ + read_from_stdin = 1; + } + else if (arg_index == argc) + /* "If there are no operands and the -c option is not specified, the -s + option shall be assumed." */ + read_from_stdin = 1; set_bash_input ();