mirror of
https://github.com/taglib/taglib.git
synced 2025-07-18 13:04:18 -04:00
Move the sanity check before the unknown frame stuff. As the code currently
is if a bogus frame is hit it may try to parse it as an UnknownFrame rather than just discarding it. CCMAIL:Espen Tveit <espen.tveit@gmail.com> git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@355686 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
@ -67,6 +67,22 @@ Frame *FrameFactory::createFrame(const ByteVector &data, bool synchSafeInts) con
|
||||
Frame *FrameFactory::createFrame(const ByteVector &data, uint version) const
|
||||
{
|
||||
Frame::Header *header = new Frame::Header(data, version);
|
||||
ByteVector frameID = header->frameID();
|
||||
|
||||
// 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) {
|
||||
delete header;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for(ByteVector::ConstIterator it = frameID.begin(); it != frameID.end(); it++) {
|
||||
if( (*it < 'A' || *it > 'Z') && (*it < '1' || *it > '9') ) {
|
||||
delete header;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// TagLib doesn't mess with encrypted frames, so just treat them
|
||||
// as unknown frames.
|
||||
@ -82,21 +98,6 @@ Frame *FrameFactory::createFrame(const ByteVector &data, uint version) const
|
||||
return new UnknownFrame(data, header);
|
||||
}
|
||||
|
||||
TagLib::ByteVector frameID = header->frameID();
|
||||
|
||||
// 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)
|
||||
return 0;
|
||||
|
||||
for(ByteVector::ConstIterator it = frameID.begin(); it != frameID.end(); it++) {
|
||||
if( (*it < 'A' || *it > 'Z') && (*it < '1' || *it > '9') ) {
|
||||
delete header;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(!updateFrame(header)) {
|
||||
delete header;
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user