]> git.ipfire.org Git - thirdparty/git.git/commit - sha1-file.c
fsck: detect trailing garbage in all object types
authorJeff King <peff@peff.net>
Fri, 13 Jan 2017 18:00:25 +0000 (13:00 -0500)
committerJunio C Hamano <gitster@pobox.com>
Sun, 15 Jan 2017 23:59:03 +0000 (15:59 -0800)
commitcce044df7f2392d0c6cb21d6dca94f01ff838727
treebf624d600e7424d9ca66b05712bc2dc7debb9cf1
parentc68b489e56431cf27f7719913ab09ddc62f95912
fsck: detect trailing garbage in all object types

When a loose tree or commit is read by fsck (or any git
program), unpack_sha1_rest() checks whether there is extra
cruft at the end of the object file, after the zlib data.
Blobs that are streamed, however, do not have this check.

For normal git operations, it's not a big deal. We know the
sha1 and size checked out, so we have the object bytes we
wanted.  The trailing garbage doesn't affect what we're
trying to do.

But since the point of fsck is to find corruption or other
problems, it should be more thorough. This patch teaches its
loose-sha1 reader to detect extra bytes after the zlib
stream and complain.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_file.c
t/t1450-fsck.sh