[sheepdog] [PATCH] dog: fix confusing code for checking arguments

Hitoshi Mitake mitake.hitoshi at gmail.com
Sun Jul 27 10:45:30 CEST 2014


On Thu, Jul 3, 2014 at 7:48 PM, Ruoyu <liangry at ucweb.com> wrote:
> This command will cause a command line core dump:
>
> dog vdi object location -i 0
>
> As you can see, vdi name is needed as an argument but the above
> command don't specify.
>
> The patch fix the bug and others caused by the same reason.
>
> Signed-off-by: Ruoyu <liangry at ucweb.com>
> ---
>  dog/common.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks.
Hitoshi

>
> diff --git a/dog/common.c b/dog/common.c
> index 13eabd2..dbe2194 100644
> --- a/dog/common.c
> +++ b/dog/common.c
> @@ -256,9 +256,9 @@ int do_generic_subcommand(struct subcommand *sub, int argc, char **argv)
>                         }
>                 }
>
> -               if (flags & CMD_NEED_ARG && argc < 5 + subcmd_depth)
> -                       subcommand_usage(argv[1], argv[2], EXIT_USAGE);
>                 optind++;
> +               if (flags & CMD_NEED_ARG && argc == optind)
> +                       subcommand_usage(argv[1], argv[2], EXIT_USAGE);
>                 ret = sub[i].fn(argc, argv);
>                 if (ret == EXIT_USAGE)
>                         subcommand_usage(argv[1], argv[2], EXIT_USAGE);
> --
> 1.8.3.2
>
>
> --
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog



More information about the sheepdog mailing list