From 2295e8d0c4cec41fbe257ddb957516a7c1a139df Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 21 Dec 2006 23:49:13 -0800 Subject: commit-tree: do not overflow MAXPARENT We have a static allocation of MAXPARENT, but that limit was not enforced, other than by a lucky invocation of the program segfaulting. Signed-off-by: Junio C Hamano --- builtin-commit-tree.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'builtin-commit-tree.c') diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c index 856f3cd841..bc28770664 100644 --- a/builtin-commit-tree.c +++ b/builtin-commit-tree.c @@ -101,6 +101,9 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) a = argv[i]; b = argv[i+1]; if (!b || strcmp(a, "-p")) usage(commit_tree_usage); + + if (parents >= MAXPARENT) + die("Too many parents (%d max)", MAXPARENT); if (get_sha1(b, parent_sha1[parents])) die("Not a valid object name %s", b); check_valid(parent_sha1[parents], commit_type); -- cgit v1.2.3