summaryrefslogtreecommitdiff
path: root/src/util/serialize.h
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-07-11 17:48:05 -0400
committerkwolekr <kwolekr@minetest.net>2015-07-13 22:38:01 -0400
commit6f07f79c2f36b007b4c0385b7df2fc4612af7aba (patch)
tree08813e7042fb9e134624a5b160e6cffc41b2bf1f /src/util/serialize.h
parentb411b6f36f98d5b317d0dbfe09df045e224b1624 (diff)
downloadminetest-6f07f79c2f36b007b4c0385b7df2fc4612af7aba.tar.gz
minetest-6f07f79c2f36b007b4c0385b7df2fc4612af7aba.tar.bz2
minetest-6f07f79c2f36b007b4c0385b7df2fc4612af7aba.zip
Add more robust error checking to deSerialize*String routines
Add serializeHexString() Clean up util/serialize.cpp
Diffstat (limited to 'src/util/serialize.h')
-rw-r--r--src/util/serialize.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/util/serialize.h b/src/util/serialize.h
index 79907799f..fcba90903 100644
--- a/src/util/serialize.h
+++ b/src/util/serialize.h
@@ -426,6 +426,9 @@ inline video::SColor readARGB8(std::istream &is)
More serialization stuff
*/
+// 8 MB is a conservative limit. Increase later if problematic.
+#define LONG_STRING_MAX (8 * 1024 * 1024)
+
// Creates a string with the length as the first two bytes
std::string serializeString(const std::string &plain);
@@ -450,6 +453,9 @@ std::string serializeJsonString(const std::string &plain);
// Reads a string encoded in JSON format
std::string deSerializeJsonString(std::istream &is);
+// Creates a string consisting of the hexadecimal representation of `data`
+std::string serializeHexString(const std::string &data, bool insert_spaces=false);
+
// Creates a string containing comma delimited values of a struct whose layout is
// described by the parameter format
bool serializeStructToString(std::string *out,