mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Prevent infinite loop in StartEncryption (#1150)
This commit is contained in:
parent
172e25fef0
commit
e6b2b87366
1 changed files with 9 additions and 3 deletions
|
|
@ -1270,12 +1270,18 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
socketWrapper.SwitchToEncrypted(secretKey);
|
||||
|
||||
//Process the next packet
|
||||
int packetID = -1;
|
||||
Queue<byte> packetData = new Queue<byte>();
|
||||
int loopPrevention = UInt16.MaxValue;
|
||||
while (true)
|
||||
{
|
||||
int packetID = -1;
|
||||
Queue<byte> packetData = new Queue<byte>();
|
||||
ReadNextPacket(ref packetID, packetData);
|
||||
if (packetID == 0x00) //Login rejected
|
||||
if (packetID < 0 || loopPrevention-- < 0) // Failed to read packet or too many iterations (issue #1150)
|
||||
{
|
||||
handler.OnConnectionLost(ChatBot.DisconnectReason.ConnectionLost, Translations.Get("error.invalid_encrypt"));
|
||||
return false;
|
||||
}
|
||||
else if (packetID == 0x00) //Login rejected
|
||||
{
|
||||
handler.OnConnectionLost(ChatBot.DisconnectReason.LoginRejected, ChatParser.ParseText(dataTypes.ReadNextString(packetData)));
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue