[PATCH] hush: Prevent segfault at unexpected EOF in script.
Denys Vlasenko
vda.linux at googlemail.com
Sun Feb 25 14:38:21 UTC 2024
On Sat, Feb 10, 2024 at 4:51 PM Dmitry Chestnykh <dm.chestnykh at gmail.com> wrote:
> See https://bugs.buildroot.org/show_bug.cgi?id=15937 .
> With this patch the execution of reproducer script
> from bugzilla leads to the following output:
> 'hush: syntax error: unexpected EOF'
>
> Signed-off-by: Dmitry Chestnykh <dm.chestnykh at gmail.com>
> ---
> shell/hush.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/shell/hush.c b/shell/hush.c
> index ca01e2b5b..0595ad592 100644
> --- a/shell/hush.c
> +++ b/shell/hush.c
> @@ -6132,6 +6132,10 @@ static int expand_on_ifs(o_string *output, int n, const char *str)
>
> if (!*str) /* EOL - do not finalize word */
> break;
> +
> + if (!G.ifs)
> + return -1;
> +
The bug is that G.ifs is NULL. It was intended to be always non-NULL.
Setting it only in run_pipe() is too late: the parsing of first statement
already may require IFS splitting.
More information about the busybox
mailing list