Skip to content

Commit

Permalink
commit-tree: do not overflow MAXPARENT
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Dec 22, 2006
1 parent fa39b6b commit 2295e8d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions builtin-commit-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2295e8d

Please sign in to comment.