From: <sv...@op...> - 2024-03-14 19:38:07
|
Author: sagamusix Date: Thu Mar 14 20:37:51 2024 New Revision: 20325 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20325 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.29/ (props changed) branches/OpenMPT-1.29/soundlib/Load_dmf.cpp Modified: branches/OpenMPT-1.29/soundlib/Load_dmf.cpp ============================================================================== --- branches/OpenMPT-1.29/soundlib/Load_dmf.cpp Thu Mar 14 20:37:30 2024 (r20324) +++ branches/OpenMPT-1.29/soundlib/Load_dmf.cpp Thu Mar 14 20:37:51 2024 (r20325) @@ -943,7 +943,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.emplace_back(chunkHeader, file.ReadChunk(chunkLength)); file.Skip(chunkSkip); } |