From 6f07f79c2f36b007b4c0385b7df2fc4612af7aba Mon Sep 17 00:00:00 2001 From: kwolekr Date: Sat, 11 Jul 2015 17:48:05 -0400 Subject: Add more robust error checking to deSerialize*String routines Add serializeHexString() Clean up util/serialize.cpp --- src/util/serialize.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/util/serialize.h') 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, -- cgit v1.2.3