mirror of
https://github.com/taglib/taglib.git
synced 2026-08-27 12:47:01 -04:00
XM: assume 40 bytes for zero sample header size (#1422)
A zero sample header size makes the sample loop consume no input, allowing crafted instrument and sample counts to cause excessive CPU and memory use during parsing. Some trackers write zero sample header sizes, some trackers ignore such values and assume a standard header size of 40 bytes. We do the same to ensure the sample loop advances.
This commit is contained in:
@@ -594,6 +594,10 @@ void XM::File::read(bool)
|
||||
sumSampleCount += sampleCount;
|
||||
// wouldn't know which header size to assume otherwise:
|
||||
READ_ASSERT(instrumentHeaderSize >= inCnt + 4 && readU32L(sampleHeaderSize));
|
||||
// Some trackers wrote zero here even though 40-byte sample headers
|
||||
// follow. The value is ignored by FastTracker 2 and other loaders.
|
||||
if(sampleHeaderSize == 0)
|
||||
sampleHeaderSize = 40;
|
||||
// skip unhandled header proportion:
|
||||
seek(instrumentHeaderSize - inCnt - 4, Current);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user