[sheepdog] [PATCH v1] fix null pointer reference in dog command

Ruoyu liangry at ucweb.com
Tue Sep 23 05:25:47 CEST 2014


On 2014年09月23日 11:11, Meng An wrote:
> From: Meng An <anmeng.an at alibaba-inc.com>
>
> In function do_generic_subcommand, we should check if argv[optind] is NULL
> before using it.
Thanks, but why we should check it first?
>
> Signed-off-by: Meng An <isolate000 at gmail.com>
> ---
>   dog/common.c |    3 +++
>   1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/dog/common.c b/dog/common.c
> index 3c4f6f5..df49792 100644
> --- a/dog/common.c
> +++ b/dog/common.c
> @@ -238,6 +238,9 @@ int do_generic_subcommand(struct subcommand *sub, int argc, char **argv)
>   		sd_err("Too deep netsted subcommands, "
>   		       "please expand MAX_SUBCMD_DEPTH");
>   		exit(EXIT_USAGE);
> +	} else if (NULL == argv[optind]) {
> +		subcommand_usage(argv[1], argv[2], EXIT_USAGE);
> +		exit(EXIT_USAGE);
>   	}
>   
>   	subcmd_stack[++subcmd_depth] = sub;





More information about the sheepdog mailing list