Author: manx
Date: Fri Mar 15 13:00:49 2024
New Revision: 20347
URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20347
Log:
Merged revision(s) 20332 from trunk/OpenMPT:
[Fix] mpt/io_read/filedata_base_unseekable.hpp: Fix integer overflow when trying to read close to uint32_max bytes from unseekable files.
........
Modified:
branches/OpenMPT-1.29/ (props changed)
branches/OpenMPT-1.29/common/mptIO.cpp
Modified: branches/OpenMPT-1.29/common/mptIO.cpp
==============================================================================
--- branches/OpenMPT-1.29/common/mptIO.cpp Fri Mar 15 12:58:51 2024 (r20346)
+++ branches/OpenMPT-1.29/common/mptIO.cpp Fri Mar 15 13:00:49 2024 (r20347)
@@ -360,10 +360,10 @@
}
if(cache.size() == 0)
{
- cache.resize(Util::AlignUp<std::size_t>(cachesize + requiredbuffersize, BUFFER_SIZE));
+ cache.resize(Util::SaturateAlignUp<std::size_t>(cachesize + requiredbuffersize, BUFFER_SIZE));
} else if(Util::ExponentialGrow(cache.size()) < cachesize + requiredbuffersize)
{
- cache.resize(Util::AlignUp<std::size_t>(cachesize + requiredbuffersize, BUFFER_SIZE));
+ cache.resize(Util::SaturateAlignUp<std::size_t>(cachesize + requiredbuffersize, BUFFER_SIZE));
} else
{
cache.resize(Util::ExponentialGrow(cache.size()));
@@ -400,7 +400,7 @@
{
return;
}
- std::size_t alignedpos = Util::AlignUp<std::size_t>(target, QUANTUM_SIZE);
+ std::size_t alignedpos = Util::SaturateAlignUp<std::size_t>(target, QUANTUM_SIZE);
std::size_t needcount = alignedpos - cachesize;
EnsureCacheBuffer(needcount);
std::size_t readcount = InternalRead(&cache[cachesize], alignedpos - cachesize);
|