@matheusbsbs / matheus-bagliano / commits / f2fdd10ab7
Fork 0

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 <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Linus Torvalds committed Dec 17, 2007 at 22:12 UTC f2fdd10ab76feb0e141fc3f9cf4e5efd87f7fcdf
1 file changed +1 -1
unpack-trees.c
+1 -1
@@ -590,7 +590,7 @@ static int merged_entry(struct cache_entry *merge, struct cache_entry *old,
590 * a match.
591 */
592 if (same(old, merge)) {
593 - *merge = *old;
593 + memcpy(merge, old, offsetof(struct cache_entry, name));
594 } else {
595 verify_uptodate(old, o);
596 invalidate_ce_path(old);