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>
This commit is contained in:
Junio C Hamano 2006-12-21 23:49:13 -08:00
Родитель fa39b6b5b1
Коммит 2295e8d0c4
1 изменённых файлов: 3 добавлений и 0 удалений

Просмотреть файл

@ -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);