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>
This commit is contained in:
Jeff King 2010-06-28 04:59:07 -04:00 committed by Junio C Hamano
parent 9eafa1201b
commit bbb1b8a35a
2 changed files with 10 additions and 0 deletions

View File

@ -614,6 +614,10 @@ static int copy(int argc, const char **argv, const char *prefix)
}
}
if (argc < 2) {
error("too few parameters");
usage_with_options(git_notes_copy_usage, options);
}
if (2 < argc) {
error("too many parameters");
usage_with_options(git_notes_copy_usage, options);

View File

@ -1044,4 +1044,10 @@ test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' '
git log -1 > output &&
test_cmp expect output
'
test_expect_success 'git notes copy diagnoses too many or too few parameters' '
test_must_fail git notes copy &&
test_must_fail git notes copy one two three
'
test_done