mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Telepathy: Common.ReadMessageBlocking: log warning instead of logging OverflowException if size header is negative
This commit is contained in:
parent
ef77c90447
commit
31c3c2f924
@ -133,13 +133,15 @@ protected static bool ReadMessageBlocking(NetworkStream stream, int MaxMessageSi
|
|||||||
// protect against allocation attacks. an attacker might send
|
// protect against allocation attacks. an attacker might send
|
||||||
// multiple fake '2GB header' packets in a row, causing the server
|
// multiple fake '2GB header' packets in a row, causing the server
|
||||||
// to allocate multiple 2GB byte arrays and run out of memory.
|
// to allocate multiple 2GB byte arrays and run out of memory.
|
||||||
if (size <= MaxMessageSize)
|
//
|
||||||
|
// also protect against size <= 0 which would cause issues
|
||||||
|
if (size > 0 && size <= MaxMessageSize)
|
||||||
{
|
{
|
||||||
// read exactly 'size' bytes for content (blocking)
|
// read exactly 'size' bytes for content (blocking)
|
||||||
content = new byte[size];
|
content = new byte[size];
|
||||||
return stream.ReadExactly(content, size);
|
return stream.ReadExactly(content, size);
|
||||||
}
|
}
|
||||||
Logger.LogWarning("ReadMessageBlocking: possible allocation attack with a header of: " + size + " bytes.");
|
Logger.LogWarning("ReadMessageBlocking: possible header attack with a header of: " + size + " bytes.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user