aboutsummaryrefslogtreecommitdiff
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-12 13:49:14 +0200
commit853cfe927fd656a2688ac2bfc81c69e1004c44df (patch)
treea31e9cccf8b225e430fb4c01c786213752d4441d
parent550e6d8fbd05ea0ab60ff3e542327efb4e9cc254 (diff)
downloadbusybox-w32-853cfe927fd656a2688ac2bfc81c69e1004c44df.tar.gz
busybox-w32-853cfe927fd656a2688ac2bfc81c69e1004c44df.tar.bz2
busybox-w32-853cfe927fd656a2688ac2bfc81c69e1004c44df.zip
lineedit: fix crash when icanon set with -echo
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 625884adf..bdae10914 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -254,7 +254,7 @@ static NOINLINE const char *get_homedir_or_NULL(void)
254 const char *home; 254 const char *home;
255 255
256# if ENABLE_SHELL_ASH || ENABLE_SHELL_HUSH 256# if ENABLE_SHELL_ASH || ENABLE_SHELL_HUSH
257 home = state->sh_get_var ? state->sh_get_var("HOME") : getenv("HOME"); 257 home = state && state->sh_get_var ? state->sh_get_var("HOME") : getenv("HOME");
258# else 258# else
259 home = getenv("HOME"); 259 home = getenv("HOME");
260# endif 260# endif
@@ -2038,7 +2038,7 @@ static void parse_and_put_prompt(const char *prmt_ptr)
2038 if (!cwd_buf) { 2038 if (!cwd_buf) {
2039 const char *home; 2039 const char *home;
2040# if EDITING_HAS_sh_get_var 2040# if EDITING_HAS_sh_get_var
2041 cwd_buf = state->sh_get_var 2041 cwd_buf = state && state->sh_get_var
2042 ? xstrdup(state->sh_get_var("PWD")) 2042 ? xstrdup(state->sh_get_var("PWD"))
2043 : xrealloc_getcwd_or_warn(NULL); 2043 : xrealloc_getcwd_or_warn(NULL);
2044# else 2044# else