diff options
author | Justin Tobler <jltobler@gmail.com> | 2025-08-02 17:08:03 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2025-08-04 13:36:35 -0700 |
commit | 56730059884ef97b60c7a2347a22bbfc009142b2 (patch) | |
tree | ec380d3e12d5a7c016db091db8fc58617b64ac32 /contrib/svn-fe/svnrdump_sim.py | |
parent | 112648dd6bdd8e4f485cd0ae11636807959d48be (diff) |
archive: flush deflate stream until Z_STREAM_END
In `archive-zip.c:write_zip_entry()` when using a stream as input for
deflating a file, the call to `git_deflate()` with Z_FINISH always
expects Z_STREAM_END to be returned. Per zlib documentation[1]:
If the parameter flush is set to Z_FINISH, pending input is
processed, pending output is flushed and deflate returns with
Z_STREAM_END if there was enough output space. If deflate
returns with Z_OK or Z_BUF_ERROR, this function must be called
again with Z_FINISH and more output space (updated avail_out)
but no more input data, until it returns with Z_STREAM_END or an
error. After deflate has returned Z_STREAM_END, the only
possible operations on the stream are deflateReset or
deflateEnd.
In scenarios where the output buffer is not large enough to write all
the compressed data, it is perfectly valid for the underlying
`deflate()` to return Z_OK. Thus, expecting a single pass of `deflate()`
here to always return Z_STREAM_END is a bug. Update the code to flush
the deflate stream until Z_STREAM_END is returned.
[1]: https://zlib.net/manual.html
Helped-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/svn-fe/svnrdump_sim.py')
0 files changed, 0 insertions, 0 deletions