Merge branch 'jt/archive-zip-deflate-fix'
The deflate codepath in "git archive --format=zip" had a longstanding bug coming from misuse of zlib API, which has been corrected. * jt/archive-zip-deflate-fix: archive: flush deflate stream until Z_STREAM_END
This commit is contained in:
@@ -492,14 +492,22 @@ static int write_zip_entry(struct archiver_args *args,
|
|||||||
|
|
||||||
zstream.next_in = buf;
|
zstream.next_in = buf;
|
||||||
zstream.avail_in = 0;
|
zstream.avail_in = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
result = git_deflate(&zstream, Z_FINISH);
|
result = git_deflate(&zstream, Z_FINISH);
|
||||||
if (result != Z_STREAM_END)
|
if (result != Z_OK && result != Z_STREAM_END)
|
||||||
die("deflate error (%d)", result);
|
die("deflate error (%d)", result);
|
||||||
|
|
||||||
git_deflate_end(&zstream);
|
|
||||||
out_len = zstream.next_out - compressed;
|
out_len = zstream.next_out - compressed;
|
||||||
|
if (out_len > 0) {
|
||||||
write_or_die(1, compressed, out_len);
|
write_or_die(1, compressed, out_len);
|
||||||
compressed_size += out_len;
|
compressed_size += out_len;
|
||||||
|
zstream.next_out = compressed;
|
||||||
|
zstream.avail_out = sizeof(compressed);
|
||||||
|
}
|
||||||
|
} while (result != Z_STREAM_END);
|
||||||
|
|
||||||
|
git_deflate_end(&zstream);
|
||||||
zip_offset += compressed_size;
|
zip_offset += compressed_size;
|
||||||
|
|
||||||
write_zip_data_desc(size, compressed_size, crc);
|
write_zip_data_desc(size, compressed_size, crc);
|
||||||
|
|||||||
Reference in New Issue
Block a user