🚨 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:
2026-11-15 22:06:51 +01:00
parent 0222c01dc8
commit ad38619b9b
+7 -1
View File
@@ -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