[prev in list] [next in list] [prev in thread] [next in thread]
List: taglib-devel
Subject: [patch] fix zero length ID3v2 frames
From: Andrew de Quincey <adq_dvb () lidskialf ! net>
Date: 2005-08-31 10:27:15
Message-ID: 200508311127.15809.adq_dvb () lidskialf ! net
[Download RAW message or body]
Hi, I had a couple of mp3 files that taglib just ignored the ID3 contents of.
Turns out they have several 0 length frames in them.
The attached patch makes taglib ignore any zero length frames completely,
while still parsing other frames correctly. I thought this would be more
fault tolerant than just attempting to parse them as normal frames - e.g. in
case we find a 0 length text frame, which would be quite invalid (no text
encoding information).
The 0length frames in the files in question were:
WOAF
WOAR
WOAS
["taglib-ignore0length.patch" (text/x-diff)]
Index: mpeg/id3v2/id3v2tag.cpp
===================================================================
--- mpeg/id3v2/id3v2tag.cpp (revision 455351)
+++ mpeg/id3v2/id3v2tag.cpp (working copy)
@@ -438,13 +438,17 @@
// Checks to make sure that frame parsed correctly.
- if(frame->size() <= 0) {
+ if(frame->size() < 0) {
delete frame;
return;
}
frameDataPosition += frame->size() + Frame::headerSize(d->header.majorVersion());
- addFrame(frame);
+ if (frame->size() == 0) {
+ delete frame;
+ } else {
+ addFrame(frame);
+ }
}
}
Index: mpeg/id3v2/id3v2framefactory.cpp
===================================================================
--- mpeg/id3v2/id3v2framefactory.cpp (revision 455351)
+++ mpeg/id3v2/id3v2framefactory.cpp (working copy)
@@ -72,7 +72,7 @@
// A quick sanity check -- make sure that the frameID is 4 uppercase Latin1
// characters. Also make sure that there is data in the frame.
- if(!frameID.size() == (version < 3 ? 3 : 4) || header->frameSize() <= 0) {
+ if(!frameID.size() == (version < 3 ? 3 : 4) || header->frameSize() < 0) {
delete header;
return 0;
}
@@ -103,6 +103,10 @@
return new UnknownFrame(data, header);
}
+ if (header->frameSize() == 0) {
+ return new UnknownFrame(data, header);
+ }
+
// updateFrame() might have updated the frame ID.
frameID = header->frameID();
_______________________________________________
taglib-devel mailing list
taglib-devel@kde.org
https://mail.kde.org/mailman/listinfo/taglib-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic