mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-04 00:02:24 +00:00
Add some sanity checking for stream_parser so it's less likely to pickup other protocols as an everquest protocol.
This commit is contained in:
parent
c1651b7dca
commit
b7c93e12de
@ -176,6 +176,11 @@ namespace StreamParser.Common.Daybreak
|
|||||||
case Opcode.SessionResponse:
|
case Opcode.SessionResponse:
|
||||||
if (_connect_code == 0)
|
if (_connect_code == 0)
|
||||||
{
|
{
|
||||||
|
if(data.Length != 21)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_connect_code = BitConverter.ToUInt32(data.Slice(2, 4));
|
_connect_code = BitConverter.ToUInt32(data.Slice(2, 4));
|
||||||
_encode_key = IPAddress.NetworkToHostOrder(BitConverter.ToInt32(data.Slice(6, 4)));
|
_encode_key = IPAddress.NetworkToHostOrder(BitConverter.ToInt32(data.Slice(6, 4)));
|
||||||
_crc_bytes = data[10];
|
_crc_bytes = data[10];
|
||||||
@ -442,6 +447,8 @@ namespace StreamParser.Common.Daybreak
|
|||||||
}
|
}
|
||||||
|
|
||||||
private bool ValidateCRC(ReadOnlySpan<byte> p)
|
private bool ValidateCRC(ReadOnlySpan<byte> p)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (_crc_bytes == 0)
|
if (_crc_bytes == 0)
|
||||||
{
|
{
|
||||||
@ -464,6 +471,10 @@ namespace StreamParser.Common.Daybreak
|
|||||||
}
|
}
|
||||||
|
|
||||||
return actual == calculated;
|
return actual == calculated;
|
||||||
|
} catch(Exception ex)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] Decompress(byte[] p, int offset, int length)
|
private byte[] Decompress(byte[] p, int offset, int length)
|
||||||
|
|||||||
@ -87,6 +87,12 @@ namespace StreamParser.Common.Daybreak
|
|||||||
}
|
}
|
||||||
else if (data[0] == 0 && data[1] == Opcode.SessionRequest)
|
else if (data[0] == 0 && data[1] == Opcode.SessionRequest)
|
||||||
{
|
{
|
||||||
|
if(data.Length != 24)
|
||||||
|
{
|
||||||
|
_logger.LogTrace("Tossing packet, {0} was not the right size for a SessionRequest", data.Length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
c = new Connection(this, srcAddr, srcPort, dstAddr, dstPort);
|
c = new Connection(this, srcAddr, srcPort, dstAddr, dstPort);
|
||||||
_connections.Add(c);
|
_connections.Add(c);
|
||||||
c.ProcessPacket(srcAddr, srcPort, packetTime, data);
|
c.ProcessPacket(srcAddr, srcPort, packetTime, data);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user