提交 bbb1b8a3 编写于 作者: J Jeff King 提交者: Junio C Hamano

notes: check number of parameters to "git notes copy"

Otherwise we may segfault with too few parameters.
Signed-off-by: NJeff King <peff@peff.net>
Tested-by: NBert Wesarg <Bert.Wesarg@googlemail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 9eafa120
......@@ -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);
......
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册