submodule: check argc count for git submodule--helper clone
authorJacob Keller <jacob.keller@gmail.com>
Mon, 29 Feb 2016 22:58:31 +0000 (14:58 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 1 Mar 2016 20:24:03 +0000 (12:24 -0800)
Extra unused arguments to git submodule--helper clone subcommand were
being silently ignored. Add a check to the argc count after options
handling to ensure that no extra arguments were left on the argv array.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Reviewed-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c
index f4c3eff179b5f25e5d09c26348c107d0582455f2..1e18075ed90f34890d75ad5d0fa2e4cb2f63d9bc 100644 (file)
@@ -194,6 +194,10 @@ static int module_clone(int argc, const char **argv, const char *prefix)
        argc = parse_options(argc, argv, prefix, module_clone_options,
                             git_submodule_helper_usage, 0);
 
        argc = parse_options(argc, argv, prefix, module_clone_options,
                             git_submodule_helper_usage, 0);
 
+       if (argc)
+               usage_with_options(git_submodule_helper_usage,
+                                  module_clone_options);
+
        strbuf_addf(&sb, "%s/modules/%s", get_git_dir(), name);
        sm_gitdir = strbuf_detach(&sb, NULL);
 
        strbuf_addf(&sb, "%s/modules/%s", get_git_dir(), name);
        sm_gitdir = strbuf_detach(&sb, NULL);