[sheepdog] [PATCH] dog: fix confusing code for checking arguments
Ruoyu
liangry at ucweb.com
Thu Jul 3 12:48:11 CEST 2014
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(-)
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
More information about the sheepdog
mailing list