b495227d9f6bd332d233e5ebd867234c74a3fbd9
[openwrt/openwrt.git] / package / utils / busybox / patches / 001-backport1330fix-ash-make-strdup-copy.patch
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
5
6 Otherwise if $HISTFILE is unset or reassigned, bad things can happen.
7
8 function old new delta
9 ash_main 1210 1218 +8
10
11 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
12 ---
13 shell/ash.c | 4 ++--
14 1 file changed, 2 insertions(+), 2 deletions(-)
15
16 diff --git a/shell/ash.c b/shell/ash.c
17 index f16d7fb6a..ecbfbf091 100644
18 --- a/shell/ash.c
19 +++ b/shell/ash.c
20 @@ -14499,7 +14499,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
21
22 if (sflag || minusc == NULL) {
23 #if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY
24 - if (iflag) {
25 + if (line_input_state) {
26 const char *hp = lookupvar("HISTFILE");
27 if (!hp) {
28 hp = lookupvar("HOME");
29 @@ -14513,7 +14513,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
30 }
31 }
32 if (hp)
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);
38 --
39 cgit v1.2.1
40