git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] bundle: verify arguments more strictly

From
Patrick Steinhardt <ps@pks.im>
Date
May 8, 2015, 08:02 UTC
Message-ID
<1431072120-24245-1-git-send-email-ps@pks.im>
In-Reply-To
<1431071341-23363-1-git-send-email-ps@pks.im>

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 <ps@pks.im>
---
Added missing Signed-off-by.
 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
Previous: Patrick SteinhardtNext: Johannes Schindelin
Message 2 of 4 in “bundle: verify arguments more strictly”
  1. bundle: verify arguments more strictlyPatrick Steinhardt, May 8, 2015
  2. bundle: verify arguments more strictlyPatrick Steinhardt, May 8, 2015
  3. Johannes SchindelinMay 8, 2015
  4. Johannes SchindelinMay 8, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.