Browse Source

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>
maint
Jeff King 15 years ago committed by Junio C Hamano
parent
commit
bbb1b8a35a
  1. 4
      builtin/notes.c
  2. 6
      t/t3301-notes.sh

4
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) { if (2 < argc) {
error("too many parameters"); error("too many parameters");
usage_with_options(git_notes_copy_usage, options); usage_with_options(git_notes_copy_usage, options);

6
t/t3301-notes.sh

@ -1044,4 +1044,10 @@ test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' '
git log -1 > output && git log -1 > output &&
test_cmp expect 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 test_done

Loading…
Cancel
Save