From f2fdd10ab76feb0e141fc3f9cf4e5efd87f7fcdf Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 17 Dec 2007 22:12:03 -0800 Subject: [PATCH] unpack-trees: FLEX_ARRAY fix In unpack-trees.c (line 593), we do .. if (same(old, merge)) { *merge = *old; } else { .. and that "merge" is a cache_entry pointer. If we have a non-zero FLEX_ARRAY size, it will cause us to copy the first few bytes of the name too. That is technically wrong even for FLEX_ARRAY being 1, but you'll never notice, since the filenames should always be the same with the current code. But if we do the same thing for a rename, we'd be screwed. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- unpack-trees.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unpack-trees.c b/unpack-trees.c index e9eb795d6..aa2513ed7 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -590,7 +590,7 @@ static int merged_entry(struct cache_entry *merge, struct cache_entry *old, * a match. */ if (same(old, merge)) { - *merge = *old; + memcpy(merge, old, offsetof(struct cache_entry, name)); } else { verify_uptodate(old, o); invalidate_ce_path(old); -- 2.30.2