tree-walk.c: do not leak internal structure in tree_entry_len()

tree_entry_len() does not simply take two random arguments and return
a tree length. The two pointers must point to a tree item structure,
or struct name_entry. Passing random pointers will return incorrect
value.

Force callers to pass struct name_entry instead of two pointers (with
hope that they don't manually construct struct name_entry themselves)

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Nguyễn Thái Ngọc Duy
2011-10-24 17:36:09 +11:00
committed by Junio C Hamano
parent 997a1946a5
commit 0de1633783
7 changed files with 20 additions and 20 deletions

2
tree.c
View File

@@ -99,7 +99,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,
else
continue;
len = tree_entry_len(entry.path, entry.sha1);
len = tree_entry_len(&entry);
strbuf_add(base, entry.path, len);
strbuf_addch(base, '/');
retval = read_tree_1(lookup_tree(sha1),