1 From 67cc582d4289c5de521d11b08307c8ab26ee1e28 Mon Sep 17 00:00:00 2001
2 From: Denys Vlasenko <vda.linux@googlemail.com>
3 Date: Sun, 3 Jan 2021 10:55:39 +0100
4 Subject: ash: make a strdup copy of $HISTFILE for line editing
6 Otherwise if $HISTFILE is unset or reassigned, bad things can happen.
11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
14 1 file changed, 2 insertions(+), 2 deletions(-)
16 diff --git a/shell/ash.c b/shell/ash.c
17 index f16d7fb6a..ecbfbf091 100644
20 @@ -14499,7 +14499,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
22 if (sflag || minusc == NULL) {
23 #if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY
25 + if (line_input_state) {
26 const char *hp = lookupvar("HISTFILE");
28 hp = lookupvar("HOME");
29 @@ -14513,7 +14513,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
33 - line_input_state->hist_file = hp;
34 + line_input_state->hist_file = xstrdup(hp);
35 # if ENABLE_FEATURE_SH_HISTFILESIZE
36 hp = lookupvar("HISTFILESIZE");
37 line_input_state->max_history = size_from_HISTFILESIZE(hp);