mirror of
https://github.com/taglib/taglib.git
synced 2026-05-25 13:08:55 -04:00
Drop zero size ID3v2 frames but accept tag (#437)
This commit is contained in:
@@ -121,9 +121,11 @@ std::pair<Frame::Header *, bool> FrameFactory::prepareFrameHeader(
|
||||
|
||||
// A quick sanity check -- make sure that the frameID is 4 uppercase Latin1
|
||||
// characters. Also make sure that there is data in the frame.
|
||||
// A frame size of zero is invalid, but tolerated here to later only drop the
|
||||
// frame but not the whole tag.
|
||||
|
||||
if(frameID.size() != (version < 3U ? 3U : 4U) ||
|
||||
header->frameSize() <= static_cast<unsigned int>(header->dataLengthIndicator() ? 4 : 0) ||
|
||||
header->frameSize() < static_cast<unsigned int>(header->dataLengthIndicator() ? 4 : 0) ||
|
||||
header->frameSize() > data.size())
|
||||
{
|
||||
delete header;
|
||||
|
||||
@@ -879,13 +879,6 @@ void ID3v2::Tag::parse(const ByteVector &origData)
|
||||
if(!frame)
|
||||
return;
|
||||
|
||||
// Checks to make sure that frame parsed correctly.
|
||||
|
||||
if(frame->size() <= 0) {
|
||||
delete frame;
|
||||
return;
|
||||
}
|
||||
|
||||
if(frame->header()->version() == headerVersion) {
|
||||
frameDataPosition += frame->size() + frame->headerSize();
|
||||
} else {
|
||||
@@ -895,7 +888,14 @@ void ID3v2::Tag::parse(const ByteVector &origData)
|
||||
Frame::Header origHeader(origData, headerVersion);
|
||||
frameDataPosition += origHeader.frameSize() + origHeader.size();
|
||||
}
|
||||
addFrame(frame);
|
||||
|
||||
if(frame->size() > 0) {
|
||||
addFrame(frame);
|
||||
} else {
|
||||
// A frame with size 0 is invalid, drop it. "A frame must be at least 1
|
||||
// byte big" (id3v2.4.0-structure.txt - 4, id3v2.3.0.txt - 3.3).
|
||||
delete frame;
|
||||
}
|
||||
}
|
||||
|
||||
d->factory->rebuildAggregateFrames(this);
|
||||
|
||||
Reference in New Issue
Block a user