diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2011-10-24 17:36:09 +1100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-10-27 11:08:26 -0700 |
commit | 0de1633783685e9fb1943551217cdda7edbd245b (patch) | |
tree | 581476c5e6b352769a391071595e625d7443db24 /tree-diff.c | |
parent | 997a1946a55cafb992c4ba8e5e0795aa73f5a4a9 (diff) | |
download | git-0de1633783685e9fb1943551217cdda7edbd245b.tar.gz |
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 'tree-diff.c')
-rw-r--r-- | tree-diff.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tree-diff.c b/tree-diff.c index b3cc2e4753..6782484489 100644 --- a/tree-diff.c +++ b/tree-diff.c @@ -21,8 +21,8 @@ static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2, sha1 = tree_entry_extract(t1, &path1, &mode1); sha2 = tree_entry_extract(t2, &path2, &mode2); - pathlen1 = tree_entry_len(path1, sha1); - pathlen2 = tree_entry_len(path2, sha2); + pathlen1 = tree_entry_len(&t1->entry); + pathlen2 = tree_entry_len(&t2->entry); cmp = base_name_compare(path1, pathlen1, mode1, path2, pathlen2, mode2); if (cmp < 0) { show_entry(opt, "-", t1, base); @@ -85,7 +85,7 @@ static void show_entry(struct diff_options *opt, const char *prefix, unsigned mode; const char *path; const unsigned char *sha1 = tree_entry_extract(desc, &path, &mode); - int pathlen = tree_entry_len(path, sha1); + int pathlen = tree_entry_len(&desc->entry); int old_baselen = base->len; strbuf_add(base, path, pathlen); |