# [PATCH] bundle: verify arguments more strictly

4 messages from 2015-05-08 to 2015-05-08. Participants: Patrick Steinhardt, Johannes Schindelin.
Thread: https://gitlist.dev/t/39272

## Patrick Steinhardt, 2015-05-08 07:49

Subject: [PATCH] bundle: verify arguments more strictly
Message-ID: <1431071341-23363-1-git-send-email-ps@pks.im>
URL: https://gitlist.dev/e/1431071341-23363-1-git-send-email-ps%40pks.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.
---
 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

```

## Patrick Steinhardt, 2015-05-08 08:02

Subject: [PATCH v2] bundle: verify arguments more strictly
Message-ID: <1431072120-24245-1-git-send-email-ps@pks.im>
URL: https://gitlist.dev/e/1431072120-24245-1-git-send-email-ps%40pks.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

```

## Johannes Schindelin, 2015-05-08 08:11

Subject: Re: [PATCH] bundle: verify arguments more strictly
Message-ID: <239a633b6bbed03e92318322ce566295@www.dscho.org>
URL: https://gitlist.dev/e/239a633b6bbed03e92318322ce566295%40www.dscho.org
In-Reply-To: <1431071341-23363-1-git-send-email-ps@pks.im>

```
Hi Patrick,

On 2015-05-08 09:49, Patrick Steinhardt wrote:
> 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.

Good catch. But please sign off your patch [*1*]

Other than that...
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>

Ciao,
Johannes

Footnote *1*: Here is why you need to sign off on your patches: https://github.com/git/git/blob/v2.3.5/Documentation/SubmittingPatches#L234-L286

```

## Johannes Schindelin, 2015-05-08 08:12

Subject: Re: [PATCH v2] bundle: verify arguments more strictly
Message-ID: <843faff92f28b479688cbc1e0dffa38d@www.dscho.org>
URL: https://gitlist.dev/e/843faff92f28b479688cbc1e0dffa38d%40www.dscho.org
In-Reply-To: <1431072120-24245-1-git-send-email-ps@pks.im>

```
Hi Patrick,

On 2015-05-08 10:02, Patrick Steinhardt wrote:

> Added missing Signed-off-by.

Hah, mid-air collision ;-)

Still: ACK!

Ciao,
Johannes

```
