Fixed error log for non-fatal inflate() return code Z_BUF_ERROR
This MR fixes logs of the kind
Failed to uncompress gzip stream (-5)
Z_BUF_ERROR
is a non-fatal return code of inflate() and indicates that input and output is empty (size 0).
We already have
if (!srclen) {
// special case to avoid decompress errors
if (dc->sink)
dc->sink(dc->context, "", 0);
return 0;
}
to avoid this case (srclen = 0).
However, during the
do {
strm->next_out = (unsigned char *) dst;
strm->avail_out = sizeof(dst);
status = inflate(strm, Z_SYNC_FLUSH);
if ((status == Z_OK || status == Z_STREAM_END) && strm->avail_out < sizeof(dst)) {
if (dc->sink)
dc->sink(dc->context, dst, sizeof(dst) - strm->avail_out);
}
} while (status == Z_OK && !strm->avail_out);
loop, inflate() may encounter a sitation where all input has been read, but no output can be returned and thus will return Z_BUF_ERROR
.
Approver's checklist:
-
The author has submitted the FSF Copyright Assignment and is listed in AUTHORS -
There is a test suite reasonably covering new functionality or modifications -
Function naming, parameters, return values, types, etc., are consistent with existing code -
This feature/change has adequate documentation added (if appropriate) -
No obvious mistakes / misspelling in the code