git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bundle: verify arguments more strictly
@ 2015-05-08  7:49 Patrick Steinhardt
  2015-05-08  8:02 ` [PATCH v2] " Patrick Steinhardt
  2015-05-08  8:11 ` [PATCH] " Johannes Schindelin
  0 siblings, 2 replies; 4+ messages in thread
From: Patrick Steinhardt @ 2015-05-08  7:49 UTC (permalink / raw)
  To: git; +Cc: Patrick Steinhardt

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.
---
 builtin/bundle.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/builtin/bundle.c b/builtin/bundle.c
index 92a8a60..4883a43 100644
--- a/builtin/bundle.c
+++ b/builtin/bundle.c
@@ -42,6 +42,10 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
 
 	if (!strcmp(cmd, "verify")) {
 		close(bundle_fd);
+		if (argc != 1) {
+			usage(builtin_bundle_usage);
+			return 1;
+		}
 		if (verify_bundle(&header, 1))
 			return 1;
 		fprintf(stderr, _("%s is okay\n"), bundle_file);
@@ -52,6 +56,10 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
 		return !!list_bundle_refs(&header, argc, argv);
 	}
 	if (!strcmp(cmd, "create")) {
+		if (argc < 2) {
+			usage(builtin_bundle_usage);
+			return 1;
+		}
 		if (!startup_info->have_repository)
 			die(_("Need a repository to create a bundle."));
 		return !!create_bundle(&header, bundle_file, argc, argv);
-- 
2.4.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-05-08  8:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-08  7:49 [PATCH] bundle: verify arguments more strictly Patrick Steinhardt
2015-05-08  8:02 ` [PATCH v2] " Patrick Steinhardt
2015-05-08  8:12   ` Johannes Schindelin
2015-05-08  8:11 ` [PATCH] " Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).