libbzip2 - BZ2_bzBuffToBuffDecompress issue

Nick Zorn nickvzorn@gmail.com
Tue Jan 1 00:00:00 GMT 2019


What that guy meant to say in the first sentence was "compressed", not
"uncompressed":

"If the size of the buffer allocated to receive the decompressed data
is bigger than the compressed data (which is completely
normal/expected, given you likely do not know how big the decompressed
data will be), one can never receive BZ_OK as a return value -- one
will only ever get BZ_UNEXPECTED_EOF."

Respectfully,
Nick



On Thu, 21 Nov 2019 22:19:46 +0000, Nick V. Zorn wrote:
> Hello bzip2 developers,
>
> I believe I found a potential issue inside the convenience function
> BZ_API(BZ2_bzBuffToBuffDecompress).
>
> If the size of the buffer allocated to receive the decompressed data is
> bigger than the compressed data (which is completely normal/expected,
> given you likely do not know how big the decompressed data will be), one can
> never receive BZ_OK as a return value -- one will only ever get
> BZ_UNEXPECTED_EOF. But more importantly, the destLen value will not be
> updated, making the returned data essentially unusable.
>
> So I made some minor modifications to the code (starting at line 1337 in
> bzlib.c), commented below. I have been using it continuously and without
> error inside an application for over a year.
>
>    output_overflow_or_eof:
>    if (strm.avail_out > 0) {
>        *destLen -= strm.avail_out; // NVZ added this line 08 Nov 2018
>        BZ2_bzDecompressEnd ( &strm );
>        return BZ_OK; // NVZ changed this return value from BZ_UNEXPECTED_EOF on 08 Nov 2018
>    } else {
>       BZ2_bzDecompressEnd ( &strm );
>       return BZ_OUTBUFF_FULL;>    };
>
> Feel free to ignore or shut this down. Otherwise, I hope I may have been
> able to identify an area for potential improvement in a great library. It's
> also nice to see people picking up the torch and continuing to support it.
>
> Thank you.



More information about the Bzip2-devel mailing list