Drop zero size ID3v2 frames but accept tag (#437)

This commit is contained in:
Urs Fleisch
2026-04-20 15:11:33 +02:00
committed by GitHub
parent a64e7543f8
commit 77f6b9add5
2 changed files with 11 additions and 9 deletions

View File

@@ -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;

View File

@@ -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);