[git commit branch/1_33_stable] ash: make a strdup copy of $HISTFILE for line editing
Denys Vlasenko
vda.linux at googlemail.com
Mon Mar 8 23:28:26 UTC 2021
commit: https://git.busybox.net/busybox/commit/?id=67cc582d4289c5de521d11b08307c8ab26ee1e28
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/1_33_stable
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 at googlemail.com>
---
shell/ash.c | 4 ++--
1 file 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)
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);
More information about the busybox-cvs
mailing list