@matheusbsbs / matheus-bagliano / commits / 2295e8d0c4
Fork 0

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>

Junio C Hamano committed Dec 21, 2006 at 23:49 UTC 2295e8d0c4cec41fbe257ddb957516a7c1a139df
1 file changed +3
builtin-commit-tree.c
+3
@@ -101,6 +101,9 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
101 a = argv[i]; b = argv[i+1];
102 if (!b || strcmp(a, "-p"))
103 usage(commit_tree_usage);
104 +
105 + if (parents >= MAXPARENT)
106 + die("Too many parents (%d max)", MAXPARENT);
107 if (get_sha1(b, parent_sha1[parents]))
108 die("Not a valid object name %s", b);
109 check_valid(parent_sha1[parents], commit_type);