Skip to content

Commit 7886cfa

Browse files
pks-tgitster
authored andcommitted
bundle: verify arguments more strictly
The `verify` and `create` subcommands of the bundle builtin do not properly verify the command line arguments that have been passed in. While the `verify` subcommand accepts an arbitrary amount of ignored arguments the `create` subcommand does not complain about being passed too few arguments, resulting in a bogus call to `git rev-list`. Fix these errors by verifying that the correct amount of arguments has been passed in. Signed-off-by: Patrick Steinhardt <[email protected]> Acked-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 282616c commit 7886cfa

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

builtin/bundle.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
4242

4343
if (!strcmp(cmd, "verify")) {
4444
close(bundle_fd);
45+
if (argc != 1) {
46+
usage(builtin_bundle_usage);
47+
return 1;
48+
}
4549
if (verify_bundle(&header, 1))
4650
return 1;
4751
fprintf(stderr, _("%s is okay\n"), bundle_file);
@@ -52,6 +56,10 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
5256
return !!list_bundle_refs(&header, argc, argv);
5357
}
5458
if (!strcmp(cmd, "create")) {
59+
if (argc < 2) {
60+
usage(builtin_bundle_usage);
61+
return 1;
62+
}
5563
if (!startup_info->have_repository)
5664
die(_("Need a repository to create a bundle."));
5765
return !!create_bundle(&header, bundle_file, argc, argv);

0 commit comments

Comments
 (0)