diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-01-03 10:55:39 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-03-09 00:28:26 +0100 |
commit | 67cc582d4289c5de521d11b08307c8ab26ee1e28 (patch) | |
tree | 741f8b52c5df073b30ed7746b125ece7a458c6f1 | |
parent | ee1e0987e4c81b4a5369174ce22b0671198abb6b (diff) | |
download | busybox-w32-67cc582d4289c5de521d11b08307c8ab26ee1e28.tar.gz busybox-w32-67cc582d4289c5de521d11b08307c8ab26ee1e28.tar.bz2 busybox-w32-67cc582d4289c5de521d11b08307c8ab26ee1e28.zip |
ash: make a strdup copy of $HISTFILE for line editing
Otherwise if $HISTFILE is unset or reassigned, bad things can happen.
function old new delta
ash_main 1210 1218 +8
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c index f16d7fb6a..ecbfbf091 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -14499,7 +14499,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv) | |||
14499 | 14499 | ||
14500 | if (sflag || minusc == NULL) { | 14500 | if (sflag || minusc == NULL) { |
14501 | #if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY | 14501 | #if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY |
14502 | if (iflag) { | 14502 | if (line_input_state) { |
14503 | const char *hp = lookupvar("HISTFILE"); | 14503 | const char *hp = lookupvar("HISTFILE"); |
14504 | if (!hp) { | 14504 | if (!hp) { |
14505 | hp = lookupvar("HOME"); | 14505 | hp = lookupvar("HOME"); |
@@ -14513,7 +14513,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv) | |||
14513 | } | 14513 | } |
14514 | } | 14514 | } |
14515 | if (hp) | 14515 | if (hp) |
14516 | line_input_state->hist_file = hp; | 14516 | line_input_state->hist_file = xstrdup(hp); |
14517 | # if ENABLE_FEATURE_SH_HISTFILESIZE | 14517 | # if ENABLE_FEATURE_SH_HISTFILESIZE |
14518 | hp = lookupvar("HISTFILESIZE"); | 14518 | hp = lookupvar("HISTFILESIZE"); |
14519 | line_input_state->max_history = size_from_HISTFILESIZE(hp); | 14519 | line_input_state->max_history = size_from_HISTFILESIZE(hp); |