@matheusbsbs / matheus-bagliano / commits / bbb1b8a35a
Fork 0

notes: check number of parameters to "git notes copy"

Otherwise we may segfault with too few parameters. Signed-off-by: Jeff King <peff@peff.net> Tested-by: Bert Wesarg <Bert.Wesarg@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jun 28, 2010 at 04:59 UTC bbb1b8a35a06203020f7ab6d1ad58bcb4afe8e93
2 files changed +10
builtin/notes.c
+4
@@ -614,6 +614,10 @@ static int copy(int argc, const char **argv, const char *prefix)
614 }
615 }
616
617 + if (argc < 2) {
618 + error("too few parameters");
619 + usage_with_options(git_notes_copy_usage, options);
620 + }
621 if (2 < argc) {
622 error("too many parameters");
623 usage_with_options(git_notes_copy_usage, options);
t/t3301-notes.sh
+6
@@ -1044,4 +1044,10 @@ test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' '
1044 git log -1 > output &&
1045 test_cmp expect output
1046 '
1047 +
1048 +test_expect_success 'git notes copy diagnoses too many or too few parameters' '
1049 + test_must_fail git notes copy &&
1050 + test_must_fail git notes copy one two three
1051 +'
1052 +
1053 test_done