From: Tsuda Kageyu Date: Tue, 6 Jan 2015 08:20:03 +0000 (+0900) Subject: Fix a wrong parameter for zlib. X-Git-Tag: v1.10beta~124^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9d91610fc0b978d6d34061bb1046317e087dc30a;p=taglib Fix a wrong parameter for zlib. z_stream.avail_in has to be the length of the input buffer. It will fail when frameDataLength is smaller than the actual compressed data size. --- diff --git a/taglib/mpeg/id3v2/id3v2frame.cpp b/taglib/mpeg/id3v2/id3v2frame.cpp index 5dc84971..bee5375a 100644 --- a/taglib/mpeg/id3v2/id3v2frame.cpp +++ b/taglib/mpeg/id3v2/id3v2frame.cpp @@ -32,7 +32,6 @@ #endif #include -#include #include #include @@ -255,13 +254,17 @@ ByteVector Frame::fieldData(const ByteVector &frameData) const if(d->header->compression() && !d->header->encryption()) { - z_stream stream; - ::memset(&stream, 0, sizeof(z_stream)); + if(frameData.size() <= frameDataOffset) { + debug("Compressed frame doesn't have enough data to decode"); + return ByteVector(); + } + + z_stream stream = {}; if(inflateInit(&stream) != Z_OK) return ByteVector(); - stream.avail_in = (uLongf) frameDataLength; + stream.avail_in = (uLongf) frameData.size() - frameDataOffset; stream.next_in = (Bytef *) frameData.data() + frameDataOffset; static const uint chunkSize = 1024; diff --git a/tests/data/compressed_id3_frame.mp3 b/tests/data/compressed_id3_frame.mp3 index 60bc8956..824d036f 100644 Binary files a/tests/data/compressed_id3_frame.mp3 and b/tests/data/compressed_id3_frame.mp3 differ