From eeb628c57e59288c707420c2aa2b40db9a2f9cbc Mon Sep 17 00:00:00 2001 From: Johannes Schultz Date: Thu, 14 Mar 2024 19:37:14 +0000 Subject: [PATCH] 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). ........ git-svn-id: https://source.openmpt.org/svn/openmpt/branches/OpenMPT-1.31@20323 56274372-70c3-4bfc-bfc3-4c3a0b034d27 --- soundlib/Load_dmf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soundlib/Load_dmf.cpp b/soundlib/Load_dmf.cpp index 58daa3c0762..94b2eb8ca03 100644 --- a/soundlib/Load_dmf.cpp +++ b/soundlib/Load_dmf.cpp @@ -934,7 +934,7 @@ bool CSoundFile::ReadDMF(FileReader &file, ModLoadingFlags loadFlags) // 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(file.BytesLeft()); chunks.chunks.push_back(ChunkReader::Item{chunkHeader, file.ReadChunk(chunkLength)}); file.Skip(chunkSkip); }