Author: sagamusix
Date: Thu Mar 14 20:37:30 2024
New Revision: 20324
URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20324
Log:
Merged revision(s) 20322 from trunk/OpenMPT:
[Fix] DMF: Avoid pretending that we want to read 4GB worth of data. This can cause a crash when libopenmpt is used with unseekable streams, in particular in 32-bit builds. Directly request FileReader::BytesLeft() bytes to be read, which we normally avoid because it causes the whole file to be pre-cached - which is what we end up doing here anyway (https://www.un4seen.com/forum/?topic=15448.msg142533#msg142533).
........
Modified:
branches/OpenMPT-1.30/ (props changed)
branches/OpenMPT-1.30/soundlib/Load_dmf.cpp
Modified: branches/OpenMPT-1.30/soundlib/Load_dmf.cpp
==============================================================================
--- branches/OpenMPT-1.30/soundlib/Load_dmf.cpp Thu Mar 14 20:37:14 2024 (r20323)
+++ branches/OpenMPT-1.30/soundlib/Load_dmf.cpp Thu Mar 14 20:37:30 2024 (r20324)
@@ -937,7 +937,7 @@
// I don't know when exactly this stopped, but I have no version 5-7 files to check (and no X-Tracker version that writes those versions).
// Since this is practically always the last chunk in the file, the following code is safe for those versions, though.
else if(fileHeader.version < 8 && chunkHeader.GetID() == DMFChunk::idSMPD)
- chunkLength = uint32_max;
+ chunkLength = mpt::saturate_cast<uint32>(file.BytesLeft());
chunks.chunks.push_back(ChunkReader::Item<DMFChunk>{chunkHeader, file.ReadChunk(chunkLength)});
file.Skip(chunkSkip);
}
|