🚨 Validate packet lengths from the server
A declared length below the header size desynced the receive queue and dispatched handlers on garbage, and an unbounded length could grow the queue without limit.
This commit is contained in:
@@ -264,11 +264,17 @@ begin
|
||||
size := packetHandler.PacketLength;
|
||||
if size = 0 then
|
||||
begin
|
||||
if FReceiveQueue.Size > 5 then
|
||||
if FReceiveQueue.Size >= 5 then
|
||||
size := FReceiveQueue.ReadCardinal
|
||||
else
|
||||
Break; //wait for more data
|
||||
end;
|
||||
if (size < 5) or (size > 32 * 1024 * 1024) then
|
||||
begin
|
||||
Disconnect;
|
||||
FReceiveQueue.Clear;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
if FReceiveQueue.Size >= size then
|
||||
begin
|
||||
|
||||
Reference in New Issue
Block a user