File tree 2 files changed +10
-4
lines changed
2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,10 @@ std::wstring deSerializeWideString(std::istream &is)
126
126
std::string serializeLongString (const std::string &plain)
127
127
{
128
128
char buf[4 ];
129
+
130
+ if (plain.size () > LONG_STRING_MAX)
131
+ throw SerializationError (" String too long for serializeLongString" );
132
+
129
133
writeU32 ((u8*)&buf[0 ], plain.size ());
130
134
std::string s;
131
135
s.append (buf, 4 );
@@ -147,8 +151,10 @@ std::string deSerializeLongString(std::istream &is)
147
151
return s;
148
152
149
153
// We don't really want a remote attacker to force us to allocate 4GB...
150
- if (s_size > LONG_STRING_MAX)
151
- throw SerializationError (" deSerializeLongString: string too long" );
154
+ if (s_size > LONG_STRING_MAX) {
155
+ throw SerializationError (" deSerializeLongString: "
156
+ " string too long: " + itos (s_size) + " bytes" );
157
+ }
152
158
153
159
Buffer<char > buf2 (s_size);
154
160
is.read (&buf2[0 ], s_size);
Original file line number Diff line number Diff line change @@ -426,8 +426,8 @@ inline video::SColor readARGB8(std::istream &is)
426
426
More serialization stuff
427
427
*/
428
428
429
- // 8 MB is a conservative limit. Increase later if problematic .
430
- #define LONG_STRING_MAX (8 * 1024 * 1024 )
429
+ // 64 MB ought to be enough for anybody - Billy G .
430
+ #define LONG_STRING_MAX (64 * 1024 * 1024 )
431
431
432
432
// Creates a string with the length as the first two bytes
433
433
std::string serializeString (const std::string &plain);
You can’t perform that action at this time.
0 commit comments