[PATCH] Sanitize ID3v2.3 frames
Xavier Duret
xaviour.maillists at gmail.com
Fri Jan 19 11:21:03 CET 2007
Valgrind revealed a memory leak with this patch. Here is an update.
diff -ruN taglib.old/taglib/mpeg/id3v2/id3v2frame.cpp
taglib/taglib/mpeg/id3v2/id3v2frame.cpp
--- taglib.old/taglib/mpeg/id3v2/id3v2frame.cpp 2007-01-17
16:01:33.000000000 +0100
+++ taglib/taglib/mpeg/id3v2/id3v2frame.cpp 2007-01-17
21:09:08.000000000 +0100
@@ -326,6 +326,11 @@
// the frame header (structure 4)
d->frameSize = data.mid(4, 4).toUInt();
+ if ((d->frameSize == 0) ||
+ ((d->frameSize == 1) && (data.mid(10, 1) ==
textDelimiter(String::Latin1)))) {
+ d->frameID = ByteVector("JUNK",4);
+ return;
+ }
{ // read the first byte of flags
std::bitset<8> flags(data[8]);
diff -ruN taglib.old/taglib/mpeg/id3v2/id3v2tag.cpp
taglib/taglib/mpeg/id3v2/id3v2tag.cpp
--- taglib.old/taglib/mpeg/id3v2/id3v2tag.cpp 2007-01-18
20:35:46.000000000 +0100
+++ taglib/taglib/mpeg/id3v2/id3v2tag.cpp 2007-01-18
20:37:04.000000000 +0100
@@ -437,7 +437,10 @@
}
frameDataPosition += frame->size() +
Frame::headerSize(d->header.majorVersion());
- addFrame(frame);
+ if (!(frame->frameID() == "JUNK"))
+ addFrame(frame);
+ else
+ delete frame;
}
}
On 1/17/07, Xavier Duret <xaviour.maillists at gmail.com> wrote:
> This patch filters out empty ID3v2.3 frames that cause taglib to
> report the genre as blues. This patch has to be applied after the
> "repeated genre" fix.
More information about the taglib-devel
mailing list