summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkos Somfai <akos.somfai@gmail.com>2023-04-03 22:52:06 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2023-04-25 16:47:22 +0200
commit38d2d26a5fec3dfd24493c8b42a90e4c413f80d5 (patch)
treefaba241c05affdc7331237b2caa3d34eaf75142a
parent384cd2e436e9b15a7ffe2bf93260d94992dc1193 (diff)
downloadbusybox-1_36_stable.tar.gz
lineedit: fix crash when icanon set with -echo1_36_stable
When icanon is set with -echo (e.g. ssh from an emacs shell) then S.state will remain null but later it will be deferenced causing ash to crash. Fix: additional check on state. Signed-off-by: Akos Somfai <akos.somfai@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/lineedit.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index ed7c42ba8..c87d6064a 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -254,7 +254,7 @@ static NOINLINE const char *get_homedir_or_NULL(void)
const char *home;
# if ENABLE_SHELL_ASH || ENABLE_SHELL_HUSH
- home = state->sh_get_var ? state->sh_get_var("HOME") : getenv("HOME");
+ home = state && state->sh_get_var ? state->sh_get_var("HOME") : getenv("HOME");
# else
home = getenv("HOME");
# endif
@@ -2038,7 +2038,7 @@ static void parse_and_put_prompt(const char *prmt_ptr)
if (!cwd_buf) {
const char *home;
# if EDITING_HAS_sh_get_var
- cwd_buf = state->sh_get_var
+ cwd_buf = state && state->sh_get_var
? xstrdup(state->sh_get_var("PWD"))
: xrealloc_getcwd_or_warn(NULL);
# else