mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 14:37:44 +00:00
Drop connection if received packet is incomplete
This commit is contained in:
parent
49e34b2fdc
commit
ef0a248444
1 changed files with 24 additions and 5 deletions
|
@ -110,13 +110,32 @@ void Core::Network::GameConnection::OnDisconnect()
|
|||
|
||||
void Core::Network::GameConnection::OnRecv( std::vector< uint8_t > & buffer )
|
||||
{
|
||||
// This is assumed packet always start with valid FFXIVARR_PACKET_HEADER for now.
|
||||
|
||||
// not enough bytes for packet header, drop connection for now.
|
||||
// TODO: buffer it
|
||||
|
||||
// Dissect packet header
|
||||
Packets::FFXIVARR_PACKET_HEADER ipcHeader;
|
||||
if ( !Network::Util::bufferToPacketHeader( buffer, ipcHeader ) )
|
||||
{
|
||||
g_log.info("FIXME: Dropping connection due to incomplete packet header.");
|
||||
g_log.info("See https://github.com/SapphireMordred/Sapphire/issues/24 for more info.");
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
// Dissect packet list
|
||||
std::vector< Packets::FFXIVARR_PACKET_RAW > packetList;
|
||||
if ( !Network::Util::bufferToPacketList( buffer, ipcHeader, packetList ) )
|
||||
{
|
||||
g_log.info("Dropping connection due to incomplete message.");
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
Network::Util::bufferToPacketList( buffer, ipcHeader, packetList );
|
||||
|
||||
// Handle it
|
||||
handlePackets( ipcHeader, packetList );
|
||||
|
||||
}
|
||||
|
||||
void Core::Network::GameConnection::OnError( const boost::system::error_code & error )
|
||||
|
|
Loading…
Add table
Reference in a new issue