forked from Mirrorlandia_minetest/minetest
Fixed a temporary solution of server shutting down to an assert(0) when a too large block metadata is sent to an old client
This commit is contained in:
parent
821d5bb4cc
commit
59c4a342a9
@ -2109,9 +2109,17 @@ void MapBlock::serialize(std::ostream &os, u8 version)
|
|||||||
{
|
{
|
||||||
if(version <= 15)
|
if(version <= 15)
|
||||||
{
|
{
|
||||||
std::ostringstream oss(std::ios_base::binary);
|
try{
|
||||||
m_node_metadata.serialize(oss);
|
std::ostringstream oss(std::ios_base::binary);
|
||||||
os<<serializeString(oss.str());
|
m_node_metadata.serialize(oss);
|
||||||
|
os<<serializeString(oss.str());
|
||||||
|
}
|
||||||
|
// This will happen if the string is longer than 65535
|
||||||
|
catch(SerializationError &e)
|
||||||
|
{
|
||||||
|
// Use an empty string
|
||||||
|
os<<serializeString("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1911,7 +1911,9 @@ inline v3f intToFloat(v3s16 p, f32 d)
|
|||||||
// Creates a string with the length as the first two bytes
|
// Creates a string with the length as the first two bytes
|
||||||
inline std::string serializeString(const std::string &plain)
|
inline std::string serializeString(const std::string &plain)
|
||||||
{
|
{
|
||||||
assert(plain.size() <= 65535);
|
//assert(plain.size() <= 65535);
|
||||||
|
if(plain.size() > 65535)
|
||||||
|
throw SerializationError("String too long for serializeString");
|
||||||
char buf[2];
|
char buf[2];
|
||||||
writeU16((u8*)&buf[0], plain.size());
|
writeU16((u8*)&buf[0], plain.size());
|
||||||
std::string s;
|
std::string s;
|
||||||
|
Loading…
Reference in New Issue
Block a user