Patch taglib to stop loading a FLAC file if it has too many metadata blocks. Fixes issue 3500.

This commit is contained in:
David Sansome 2013-02-17 18:39:49 +11:00
parent 115964d1b4
commit 446b379111
2 changed files with 38 additions and 0 deletions

View File

@ -416,9 +416,18 @@ void FLAC::File::scan()
d->blocks.append(new UnknownMetadataBlock(blockType, d->streamInfoData));
nextBlockOffset += length + 4;
int blockCount = 0;
// Search through the remaining metadata
while(!isLastBlock) {
if (++blockCount > 1024) {
debug("FLAC::File::scan() -- FLAC stream has more than 1024 metadata "
"blocks, probably corrupt.");
setValid(false);
return;
}
header = readBlock(4);
blockType = header[0] & 0x7f;
isLastBlock = (header[0] & 0x80) != 0;

View File

@ -0,0 +1,29 @@
commit 0b55f03fa092241dd4533ef0fd4a18b2d97a1b25
Author: David Sansome <me@davidsansome.com>
Date: Sun Feb 17 18:39:49 2013 +1100
Stop loading a FLAC file if it has too many metadata blocks.
diff --git a/3rdparty/taglib/flac/flacfile.cpp b/3rdparty/taglib/flac/flacfile.cpp
index a02770a..d308256 100644
--- a/3rdparty/taglib/flac/flacfile.cpp
+++ b/3rdparty/taglib/flac/flacfile.cpp
@@ -416,9 +416,18 @@ void FLAC::File::scan()
d->blocks.append(new UnknownMetadataBlock(blockType, d->streamInfoData));
nextBlockOffset += length + 4;
+ int blockCount = 0;
+
// Search through the remaining metadata
while(!isLastBlock) {
+ if (++blockCount > 1024) {
+ debug("FLAC::File::scan() -- FLAC stream has more than 1024 metadata "
+ "blocks, probably corrupt.");
+ setValid(false);
+ return;
+ }
+
header = readBlock(4);
blockType = header[0] & 0x7f;
isLastBlock = (header[0] & 0x80) != 0;