On Mon, Aug 3, 2015 at 2:46 PM, Ron Yorston <[email protected]> wrote:
> busybox sh -c 'command --' segfaults because parse_command_args
> returns a pointer to a null pointer.
>
> Based on commit 18071c7 from git://git.kernel.org/pub/scm/utils/dash/dash.git
> by Gerrit Pape.
>
> function                                             old     new   delta
> evalcommand                                         1368    1350     -18
> ------------------------------------------------------------------------------
> (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-18)             Total: -18 bytes
>
> Signed-off-by: Ron Yorston <[email protected]>
> ---
>  shell/ash.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/shell/ash.c b/shell/ash.c
> index 7f3808b..ddcd28b 100644
> --- a/shell/ash.c
> +++ b/shell/ash.c
> @@ -8885,8 +8885,8 @@ parse_command_args(char **argv, const char **path)
>                 if (!c)
>                         break;
>                 if (c == '-' && !*cp) {
> -                       argv++;
> -                       break;
> +                       if (!*++argv)
> +                               return 0;

You lost "break".
Now -- doesn't work:

    sh -c 'command -- -p'

now parses -p as an option.

Applied with some edits. Thanks!
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to