[PATCH 3/5] ash: fix command -- crash
Denys Vlasenko
vda.linux at googlemail.com
Thu Oct 29 18:48:24 UTC 2015
On Mon, Aug 3, 2015 at 2:46 PM, Ron Yorston <rmy at pobox.com> 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 <rmy at pobox.com>
> ---
> 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!
More information about the busybox
mailing list