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:
Acts1631
2026-08-19 05:36:58 +02:00
committed by GitHub
parent fa4c623ab1
commit 94f7b5af4c
+4
View File
@@ -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);