From ea82b2a0857e3e0449bdce4e3987dee6adbc51ae Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Tue, 15 Jan 2019 00:39:44 +0000 Subject: tree-walk: store object_id in a separate member When parsing a tree, we read the object ID directly out of the tree buffer. This is normally fine, but such an object ID cannot be used with oidcpy, which copies GIT_MAX_RAWSZ bytes, because if we are using SHA-1, there may not be that many bytes to copy. Instead, store the object ID in a separate struct member. Since we can no longer efficiently compute the path length, store that information as well in struct name_entry. Ensure we only copy the object ID into the new buffer if the path length is nonzero, as some callers will pass us an empty path with no object ID following it, and we will not want to read past the end of the buffer. Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- walker.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'walker.c') diff --git a/walker.c b/walker.c index 96990d84da..d74ae59c77 100644 --- a/walker.c +++ b/walker.c @@ -50,13 +50,13 @@ static int process_tree(struct walker *walker, struct tree *tree) continue; if (S_ISDIR(entry.mode)) { struct tree *tree = lookup_tree(the_repository, - entry.oid); + &entry.oid); if (tree) obj = &tree->object; } else { struct blob *blob = lookup_blob(the_repository, - entry.oid); + &entry.oid); if (blob) obj = &blob->object; } -- cgit v1.2.3