summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2011-10-24 06:36:09 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-10-27 18:08:26 (GMT)
commit0de1633783685e9fb1943551217cdda7edbd245b (patch)
tree581476c5e6b352769a391071595e625d7443db24 /builtin
parent997a1946a55cafb992c4ba8e5e0795aa73f5a4a9 (diff)
downloadgit-0de1633783685e9fb1943551217cdda7edbd245b.zip
git-0de1633783685e9fb1943551217cdda7edbd245b.tar.gz
git-0de1633783685e9fb1943551217cdda7edbd245b.tar.bz2
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>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/grep.c2
-rw-r--r--builtin/pack-objects.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index 7d0779f..2cd0612 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -547,7 +547,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
int old_baselen = base->len;
while (tree_entry(tree, &entry)) {
- int te_len = tree_entry_len(entry.path, entry.sha1);
+ int te_len = tree_entry_len(&entry);
if (match != 2) {
match = tree_entry_interesting(&entry, base, tn_len, pathspec);
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index ba3705d..b4f7855 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -979,7 +979,7 @@ static void add_pbase_object(struct tree_desc *tree,
while (tree_entry(tree,&entry)) {
if (S_ISGITLINK(entry.mode))
continue;
- cmp = tree_entry_len(entry.path, entry.sha1) != cmplen ? 1 :
+ cmp = tree_entry_len(&entry) != cmplen ? 1 :
memcmp(name, entry.path, cmplen);
if (cmp > 0)
continue;