Skip to content

Commit

Permalink
notes: check number of parameters to "git notes copy"
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Jun 28, 2010
1 parent 9eafa12 commit bbb1b8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions builtin/notes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions t/t3301-notes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit bbb1b8a

Please sign in to comment.