]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/repack.c
repack: check error writing to pack-objects subprocess
authorJunio C Hamano <gitster@pobox.com>
Sat, 2 Mar 2024 19:03:48 +0000 (11:03 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sat, 2 Mar 2024 19:12:16 +0000 (11:12 -0800)
commit4c9355ff48a33eb60a4f2a51f08939320cf3f2d3
treed5c6eb4f5a3e36f14120e150520e78033a00ee4c
parent36ffba1c7be8d831065adab73a7a215f402ef432
repack: check error writing to pack-objects subprocess

When "git repack" repacks promisor objects, it starts a pack-objects
subprocess and uses xwrite() to send object names over the pipe to
it, but without any error checking.  An I/O error or short write
(even though a short write is unlikely for such a small amount of
data) can result in a packfile that lacks certain objects we wanted
to put in there, leading to a silent repository corruption.

Use write_in_full(), instead of xwrite(), to mitigate short write
risks, check errors from it, and abort if we see a failure.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/repack.c