From 3459bc1ede4ebbb8177444cc2b265ecea0678dea Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 25 Sep 2014 19:42:35 +0200 Subject: [PATCH] Protocol 1.8: Added checks for values presence. Reported by @worktycho / Coverity. --- src/Protocol/Protocol18x.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp index 94eaa43db..c07441ef7 100644 --- a/src/Protocol/Protocol18x.cpp +++ b/src/Protocol/Protocol18x.cpp @@ -1966,13 +1966,19 @@ void cProtocol180::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) void cProtocol180::HandlePacketLoginEncryptionResponse(cByteBuffer & a_ByteBuffer) { UInt32 EncKeyLength, EncNonceLength; - a_ByteBuffer.ReadVarInt(EncKeyLength); + if (!a_ByteBuffer.ReadVarInt(EncKeyLength)) + { + return; + } AString EncKey; if (!a_ByteBuffer.ReadString(EncKey, EncKeyLength)) { return; } - a_ByteBuffer.ReadVarInt(EncNonceLength); + if (!a_ByteBuffer.ReadVarInt(EncNonceLength)) + { + return; + } AString EncNonce; if (!a_ByteBuffer.ReadString(EncNonce, EncNonceLength)) {