From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121475 invoked by alias); 23 Nov 2019 15:50:15 -0000 Mailing-List: contact bzip2-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: List-Id: Sender: bzip2-devel-owner@sourceware.org Received: (qmail 121466 invoked by uid 89); 23 Nov 2019 15:50:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.3 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Received:a81 X-Spam-Status: No, score=-0.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sourceware.org X-Spam-Level: X-HELO: mail-yw1-f54.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=+DuEglvpUKrCfR8lX74L6nHyuu+spFuSMz/6XMV5n50=; b=e8bEMUgXGpcpNDqCNWcdhvv/u8JSA2dxmVk4e1uDEGrP2DOxnS9ZvfeiCN5f97DdV5 82Lt2vJFr97t2N5rTE2KeQTHQwdVtdGa52vyB3GoPCCEZdgsM4Yp+W7nNW+q9qj/hSl5 BOVFjx7B6qGkyb/mh3KBfnCz+34i7/BwAjzwpm2lDG1sooaDaOtVAi0J0lq1z0pv4xD2 YaaKko9E1W/7KB1NC1zKf4NCJZAQvtLdInejR3L1ytUFkMkdMqK3tczQiiaDdNJImaem SQW3UDeXXqH5RtQ0wVCelWD7+BchpopHsruol2+3oY7T5Zuv31v13e9TqIu6CCLQp53P vahw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=+DuEglvpUKrCfR8lX74L6nHyuu+spFuSMz/6XMV5n50=; b=mepafZb+jxCij1yWxTzSTEWzsLjm3Ctc4cqm1C1ViaNuX/E8n0zeBrOldYiSFMoLXH BEPk4anEglX0suGWTHfVF3IKmh0gfGw3O2vnPaRWzmA1RIsCU5PDEAtw4evtfWHWGEub QaBWq0rp9e7Lgxk8TpySbI+2A0jv2vlqlYjkrFWI12iYEUvKj4X2BTDC40x0caATPUPI UM+a9nk27rkCpWoNFPLH3DOGh4fzsqOogKHjFdByjpn9aK8g5Z2ixxiObeiq+02Yl1vD ffxJYIl/EfIMVVOZMGAYAGsNvel8GAzU/xF9iC+w4Ht9dPwnat0/YeukIDe8lMmT3lXs 1eLA== X-Gm-Message-State: APjAAAXmTjUQ4g41Cq3wH7/X+UspE9zCgaIt4fJg4do2xo05MpjaS9Xp A5JN7wiqe0jvc6e/ASkPZ+C29fo1xzO80h/lAFS6ob3z X-Google-Smtp-Source: APXvYqxvcSuxgjWcmbmJSzLg4W5eNiUq4sjbj0hC2B6TVOfQrInQVX5cJBxt3L2OieqRY069git8bEokMzm2FK72de0= X-Received: by 2002:a81:4b48:: with SMTP id y69mr10087988ywa.225.1574524212255; Sat, 23 Nov 2019 07:50:12 -0800 (PST) MIME-Version: 1.0 From: Nick Zorn Date: Tue, 01 Jan 2019 00:00:00 -0000 Message-ID: Subject: Re: libbzip2 - BZ2_bzBuffToBuffDecompress issue To: bzip2-devel@sourceware.org Content-Type: text/plain; charset="UTF-8" X-SW-Source: 2019-q4/txt/msg00003.txt.bz2 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.