From 4b78b933938cf851733aec805bc6c233ef2d6fdf Mon Sep 17 00:00:00 2001 From: Steve Kuznetsov Date: Tue, 5 Jul 2016 09:35:49 -0400 Subject: [PATCH] Removed environment variable substitution step from stacktrace An unintended consequence of attempting to substitute envars in the stacktrace was that subshell literals would be eval- uated as well, which is surprising in that a stacktrace should not be excecuting arbitrary code and incorrect in that any non-reentrant code when executed by the stacktrace would lead to errors elsewhere. Signed-off-by: Steve Kuznetsov --- hack/lib/log/stacktrace.sh | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/hack/lib/log/stacktrace.sh b/hack/lib/log/stacktrace.sh index 798c10e3b2d0..34e34cb32dda 100644 --- a/hack/lib/log/stacktrace.sh +++ b/hack/lib/log/stacktrace.sh @@ -42,16 +42,6 @@ function os::log::stacktrace::print() { local return_code=$1 local last_command=$2 local errexit_set=${3:-} - set -- - - # evaulate all of the variables in the last command literal so we have a useful stacktrace - # this will *not* be able to capture positional variables ($1, $@, $*) or variables declared - # in this scope or in the trap handler ($return_code, $last_command, $errexit_set) - # Furthermore, since it is possible that the failure in the last command itself was an unset - # variable, we need to turn off that check to ensure we're not re-triggering it here. - set +o nounset - local -r last_command_with_vars="$( eval "echo \"${last_command}\"" )" - set -o nounset if [[ "${return_code}" = "0" ]]; then # we're not supposed to respond when no error has occurred @@ -82,8 +72,6 @@ function os::log::stacktrace::print() { if [[ -z "${preamble_finished:-}" ]]; then preamble_finished=true os::log::error "PID ${BASHPID:-$$}: ${bash_source}:${BASH_LINENO[$i-1]}: \`${last_command}\` exited with status ${return_code}." >&2 - os::log::error "Command with variables substituted is: " - os::log::error $'\t'"${last_command_with_vars}" os::log::info $'\t\t'"Stack Trace: " >&2 os::log::info $'\t\t'" ${stack_index}: ${bash_source}:${BASH_LINENO[$i-1]}: \`${last_command}\`" >&2 else