Skip to content

Commit bbb1b8a

Browse files
peffgitster
authored andcommitted
notes: check number of parameters to "git notes copy"
Otherwise we may segfault with too few parameters. Signed-off-by: Jeff King <[email protected]> Tested-by: Bert Wesarg <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9eafa12 commit bbb1b8a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

builtin/notes.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,10 @@ static int copy(int argc, const char **argv, const char *prefix)
614614
}
615615
}
616616

617+
if (argc < 2) {
618+
error("too few parameters");
619+
usage_with_options(git_notes_copy_usage, options);
620+
}
617621
if (2 < argc) {
618622
error("too many parameters");
619623
usage_with_options(git_notes_copy_usage, options);

t/t3301-notes.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,4 +1044,10 @@ test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' '
10441044
git log -1 > output &&
10451045
test_cmp expect output
10461046
'
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+
10471053
test_done

0 commit comments

Comments
 (0)