diff options
author | Jeff King <peff@peff.net> | 2010-06-28 04:59:07 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-06-28 09:15:15 -0700 |
commit | bbb1b8a35a06203020f7ab6d1ad58bcb4afe8e93 (patch) | |
tree | c7e4500bf95872f4ffa394fef1af3ebac236a72a | |
parent | msvc: Fix some compiler warnings (diff) | |
download | tgif-bbb1b8a35a06203020f7ab6d1ad58bcb4afe8e93.tar.xz |
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>
-rw-r--r-- | builtin/notes.c | 4 | ||||
-rwxr-xr-x | t/t3301-notes.sh | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/builtin/notes.c b/builtin/notes.c index da504ee0af..f678f9cb52 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -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); diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh index 64f32ad94d..2d67a40fc1 100755 --- a/t/t3301-notes.sh +++ b/t/t3301-notes.sh @@ -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 |