[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH] lineedit: fix crash when icanon set with -echo
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2023-04-12 11:45:21
Message-ID: CAK1hOcPHD3JN9DatjOCsKBJ++gCipDbR19t2tgm7AwmOG6YviA () mail ! gmail ! com
[Download RAW message or body]

Applied, thank you.

On Mon, Apr 3, 2023 at 10:53 PM Akos Somfai <akos.somfai@gmail.com> wrote:
>
> 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.
> ---
>  libbb/lineedit.c | 4 ++--
>  1 file 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)
>         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
> --
> 2.40.0
>
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic