public inbox for bzip2-devel@sourceware.org
 help / color / mirror / Atom feed
From: "Zorn, Nicholas - 0991 - MITLL" <zorn@ll.mit.edu>
To: "bzip2-devel@sourceware.org" <bzip2-devel@sourceware.org>
Subject: libbzip2 - BZ2_bzBuffToBuffDecompress issue
Date: Tue, 01 Jan 2019 00:00:00 -0000	[thread overview]
Message-ID: <3f270c7a78e745948191a9e367c78b93@ll.mit.edu> (raw)

[-- Attachment #1: Type: text/plain, Size: 1491 bytes --]

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 uncompressed 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.
-------------------------------------------
Nick V. Zorn
Technical Staff
MIT Lincoln Laboratory
-------------------------------------------


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 7659 bytes --]

             reply	other threads:[~2019-11-21 22:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-01  0:00 Zorn, Nicholas - 0991 - MITLL [this message]
2019-01-01  0:00 Nick Zorn
2020-06-02 21:46 ` Nick Zorn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3f270c7a78e745948191a9e367c78b93@ll.mit.edu \
    --to=zorn@ll.mit.edu \
    --cc=bzip2-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).