Fix PSv parsing
I took extra care to not mess up signedness in readOPS inab600780d0
, but apparently didn't do the same in readPSv. Also fix a bound check that was broken sinceaac6b7258c
. It's a good thing this was broken, because this allowed negative type values from broken signedness readPSv to get past and cause a crash later on, rather than just cause particles to disappear or something.
This commit is contained in:
parent
b57db7991a
commit
54cd259a18
@ -1317,8 +1317,8 @@ void GameSave::readPSv(const std::vector<char> &dataVec)
|
|||||||
if (size > 209715200 || !size)
|
if (size > 209715200 || !size)
|
||||||
throw ParseException(ParseException::InvalidDimensions, "Save data too large");
|
throw ParseException(ParseException::InvalidDimensions, "Save data too large");
|
||||||
|
|
||||||
std::vector<char> data;
|
std::vector<char> bsonData;
|
||||||
switch (auto status = BZ2WDecompress(data, (char *)(saveData + 12), dataLength - 12, size))
|
switch (auto status = BZ2WDecompress(bsonData, (char *)(saveData + 12), dataLength - 12, size))
|
||||||
{
|
{
|
||||||
case BZ2WDecompressOk: break;
|
case BZ2WDecompressOk: break;
|
||||||
case BZ2WDecompressNomem: throw ParseException(ParseException::Corrupt, "Cannot allocate memory");
|
case BZ2WDecompressNomem: throw ParseException(ParseException::Corrupt, "Cannot allocate memory");
|
||||||
@ -1326,7 +1326,8 @@ void GameSave::readPSv(const std::vector<char> &dataVec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
setSize(bw, bh);
|
setSize(bw, bh);
|
||||||
dataLength = data.size();
|
const auto *data = reinterpret_cast<unsigned char *>(&bsonData[0]);
|
||||||
|
dataLength = bsonData.size();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
std::cout << "Parsing " << dataLength << " bytes of data, version " << ver << std::endl;
|
std::cout << "Parsing " << dataLength << " bytes of data, version " << ver << std::endl;
|
||||||
|
@ -105,7 +105,7 @@ int Simulation::Load(const GameSave * originalSave, bool includePressure, int fu
|
|||||||
}
|
}
|
||||||
|
|
||||||
int type = tempPart->type;
|
int type = tempPart->type;
|
||||||
if (type < 0 && type >= PT_NUM)
|
if (type < 0 || type >= PT_NUM)
|
||||||
{
|
{
|
||||||
tempPart->type = 0;
|
tempPart->type = 0;
|
||||||
continue;
|
continue;
|
||||||
|
Reference in New Issue
Block a user