mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Utils: Fix potential ID3v1 false positive in the presence of an APE tag.
This commit is contained in:
parent
197d2a684b
commit
cebaf9a8e2
@ -38,11 +38,22 @@ long Utils::findID3v1(File *file)
|
||||
if(!file->isValid())
|
||||
return -1;
|
||||
|
||||
file->seek(-128, File::End);
|
||||
const long p = file->tell();
|
||||
// Differentiate between a match of APEv2 magic and a match of ID3v1 magic.
|
||||
|
||||
if(file->readBlock(3) == ID3v1::Tag::fileIdentifier())
|
||||
return p;
|
||||
if (file->length() >= 131) {
|
||||
file->seek(-131, File::End);
|
||||
const long p = file->tell() + 3;
|
||||
const TagLib::ByteVector data = file->readBlock(8);
|
||||
|
||||
if(data.containsAt(ID3v1::Tag::fileIdentifier(), 3) && (data != APE::Tag::fileIdentifier()))
|
||||
return p;
|
||||
} else {
|
||||
file->seek(-128, File::End);
|
||||
const long p = file->tell();
|
||||
|
||||
if(file->readBlock(3) == ID3v1::Tag::fileIdentifier())
|
||||
return p;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user