aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-01-03 10:55:39 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2021-01-03 10:55:39 +0100
commit3f8ec00b0c54790283cfec675716ef4b8e00bd8a (patch)
tree89d99ff038dea5ee9cb9911f2a4783cd373832e0 /shell
parent5f2e00f66d11d99dad16c259aff331908bca4267 (diff)
downloadbusybox-3f8ec00b0c54790283cfec675716ef4b8e00bd8a.tar.gz
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>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 54f004375..f9d59e50e 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -14499,7 +14499,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
if (sflag || minusc == NULL) {
#if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY
- if (iflag) {
+ if (line_input_state) {
const char *hp = lookupvar("HISTFILE");
if (!hp) {
hp = lookupvar("HOME");
@@ -14513,7 +14513,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
}
}
if (hp)
- line_input_state->hist_file = hp;
+ line_input_state->hist_file = xstrdup(hp);
# if ENABLE_FEATURE_SH_HISTFILESIZE
hp = lookupvar("HISTFILESIZE");
line_input_state->max_history = size_from_HISTFILESIZE(hp);