Protocol: Do not assume anything about unknown packets. (#3647)
This commit is contained in:
parent
f4de38af80
commit
e4b60b6a26
@ -70,8 +70,13 @@ AString cProtocolRecognizer::GetVersionTextFromInt(int a_ProtocolVersion)
|
||||
|
||||
void cProtocolRecognizer::DataReceived(const char * a_Data, size_t a_Size)
|
||||
{
|
||||
if (m_Protocol == nullptr)
|
||||
if (m_Protocol != nullptr)
|
||||
{
|
||||
// Protocol was already recognized, send to the handler:
|
||||
m_Protocol->DataReceived(a_Data, a_Size);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_Buffer.Write(a_Data, a_Size))
|
||||
{
|
||||
m_Client->Kick("Unsupported protocol version");
|
||||
@ -91,8 +96,11 @@ void cProtocolRecognizer::DataReceived(const char * a_Data, size_t a_Size)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ASSERT(PacketID == 0x01); // Ping packet
|
||||
ASSERT(PacketLen == 9); // Payload of the packet ID and a UInt64
|
||||
if ((PacketID != 0x01) || (PacketLen != 9))
|
||||
{
|
||||
// Not a Ping packet
|
||||
return;
|
||||
}
|
||||
|
||||
Int64 Data;
|
||||
if (!m_Buffer.ReadBEInt64(Data))
|
||||
@ -115,11 +123,6 @@ void cProtocolRecognizer::DataReceived(const char * a_Data, size_t a_Size)
|
||||
m_Buffer.ResetRead();
|
||||
m_Buffer.ReadAll(Dump);
|
||||
m_Protocol->DataReceived(Dump.data(), Dump.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Protocol->DataReceived(a_Data, a_Size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user