diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-05-03 17:33:51 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-05-03 17:33:51 +0300 |
commit | 59c4a342a9625fe37e9a7aa755e6deca14c3a110 (patch) | |
tree | b5a463224681e6c4bd9ccd010a8b9d437e1567ee /src | |
parent | 821d5bb4cc3a9047187955ab897ea28f9b9aa957 (diff) | |
download | minetest-59c4a342a9625fe37e9a7aa755e6deca14c3a110.tar.gz minetest-59c4a342a9625fe37e9a7aa755e6deca14c3a110.tar.bz2 minetest-59c4a342a9625fe37e9a7aa755e6deca14c3a110.zip |
Fixed a temporary solution of server shutting down to an assert(0) when a too large block metadata is sent to an old client
Diffstat (limited to 'src')
-rw-r--r-- | src/mapblock.cpp | 14 | ||||
-rw-r--r-- | src/utility.h | 4 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/mapblock.cpp b/src/mapblock.cpp index f84c65176..67e7e2574 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -2109,9 +2109,17 @@ void MapBlock::serialize(std::ostream &os, u8 version) { if(version <= 15) { - std::ostringstream oss(std::ios_base::binary); - m_node_metadata.serialize(oss); - os<<serializeString(oss.str()); + try{ + std::ostringstream oss(std::ios_base::binary); + 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 { diff --git a/src/utility.h b/src/utility.h index 5cb3080a7..12d732bea 100644 --- a/src/utility.h +++ b/src/utility.h @@ -1911,7 +1911,9 @@ inline v3f intToFloat(v3s16 p, f32 d) // Creates a string with the length as the first two bytes 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]; writeU16((u8*)&buf[0], plain.size()); std::string s; |