Skip to content

Commit

Permalink
[Fix] DMF: Avoid pretending that we want to read 4GB worth of data. T…
Browse files Browse the repository at this point in the history
…his 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/trunk/OpenMPT@20322 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
sagamusix committed Mar 14, 2024
1 parent ce20605 commit f40c927
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion soundlib/Load_dmf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32>(file.BytesLeft());
chunks.chunks.push_back(ChunkReader::Item<DMFChunk>{chunkHeader, file.ReadChunk(chunkLength)});
file.Skip(chunkSkip);
}
Expand Down

0 comments on commit f40c927

Please sign in to comment.