summaryrefslogtreecommitdiff
path: root/builtin-commit-tree.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-12-22 07:49:13 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-12-22 07:49:13 (GMT)
commit2295e8d0c4cec41fbe257ddb957516a7c1a139df (patch)
tree91c2f64c8d95b9857e574239218cb63be8b51e3a /builtin-commit-tree.c
parentfa39b6b5b11f9b580c515a7b4a8e4eb8eaa79b75 (diff)
downloadgit-2295e8d0c4cec41fbe257ddb957516a7c1a139df.zip
git-2295e8d0c4cec41fbe257ddb957516a7c1a139df.tar.gz
git-2295e8d0c4cec41fbe257ddb957516a7c1a139df.tar.bz2
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 <junkio@cox.net>
Diffstat (limited to 'builtin-commit-tree.c')
-rw-r--r--builtin-commit-tree.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c
index 856f3cd..bc28770 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);