forked from rosebudai/OpenRCT2-Web
Fix potential crash on corrupted network data
This commit is contained in:
3 files changed
+23
-10
No files matched your search
@@ -61,13 +61,14 @@ NetworkReadPacket NetworkConnection::ReadPacket()
|
||||
|
||||
// NOTE: For compatibility reasons for the master server we need to remove sizeof(Header.Id) from the size.
|
||||
// Previously the Id field was not part of the header rather part of the body.
|
||||
header.Size -= sizeof(header.Id);
|
||||
header.Size -= std::min<uint16_t>(header.Size, sizeof(header.Id));
|
||||
|
||||
// Fall-through: Read rest of packet.
|
||||
}
|
||||
|
||||
// Read packet body.
|
||||
{
|
||||
// NOTE: BytesTransfered includes the header length, this will not underflow.
|
||||
const size_t missingLength = header.Size - (InboundPacket.BytesTransferred - sizeof(header));
|
||||
|
||||
uint8_t buffer[NetworkBufferSize];
|
||||
|
||||
Reference in new issue
Block a user