Core/Network: Fix packet size underflow

This commit is contained in:
luis
2026-11-17 08:24:33 -03:00
parent 4c71a2219e
commit 93c3c17e3a
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -345,7 +345,7 @@ bool WorldSocket::ReadHeaderHandler()
_authCrypt.PeekDecryptRecv(reinterpret_cast<uint8*>(&header->EncryptedOpcode), sizeof(encryptedOpcode));
// CMSG_HOTFIX_REQUEST can be much larger than normal packets, allow receiving it once per session
if (header->EncryptedOpcode != CMSG_HOTFIX_REQUEST || header->Size > 0x100000 || !_canRequestHotfixes)
if (header->EncryptedOpcode != CMSG_HOTFIX_REQUEST || !header->IsValidLargeSize() || !_canRequestHotfixes)
{
TC_LOG_ERROR("network", "WorldSocket::ReadHeaderHandler(): client {} sent malformed packet (size: {}, opcode {})",
GetRemoteIpAddress(), header->Size, uint32(header->EncryptedOpcode));
+2 -1
View File
@@ -70,7 +70,8 @@ struct PacketHeader
uint32 Size;
uint8 Tag[12];
bool IsValidSize() const { return Size < 0x10000; }
bool IsValidSize() const { return Size >= 4 && Size < 0x10000; }
bool IsValidLargeSize() const { return Size >= 4 && Size < 0x100000; }
};
struct IncomingPacketHeader : PacketHeader