summaryrefslogtreecommitdiffstats
path: root/src/Protocol/ProtocolRecognizer.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-09-01 20:57:55 +0200
committerMattes D <github@xoft.cz>2014-09-01 20:57:55 +0200
commit3093f3d180064738cdbfea56ea39f922648fc18c (patch)
tree5c1be5bb3055d4edf9c48a29a74d55c3a337e71d /src/Protocol/ProtocolRecognizer.cpp
parentFixed Bindings regeneration under MSVC. (diff)
parentMake sure packets are valid (diff)
downloadcuberite-3093f3d180064738cdbfea56ea39f922648fc18c.tar
cuberite-3093f3d180064738cdbfea56ea39f922648fc18c.tar.gz
cuberite-3093f3d180064738cdbfea56ea39f922648fc18c.tar.bz2
cuberite-3093f3d180064738cdbfea56ea39f922648fc18c.tar.lz
cuberite-3093f3d180064738cdbfea56ea39f922648fc18c.tar.xz
cuberite-3093f3d180064738cdbfea56ea39f922648fc18c.tar.zst
cuberite-3093f3d180064738cdbfea56ea39f922648fc18c.zip
Diffstat (limited to '')
-rw-r--r--src/Protocol/ProtocolRecognizer.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index c831da251..8b395230a 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -979,9 +979,18 @@ bool cProtocolRecognizer::TryRecognizeLengthedProtocol(UInt32 a_PacketLengthRema
AString ServerAddress;
short ServerPort;
UInt32 NextState;
- m_Buffer.ReadVarUTF8String(ServerAddress);
- m_Buffer.ReadBEShort(ServerPort);
- m_Buffer.ReadVarInt(NextState);
+ if (!m_Buffer.ReadVarUTF8String(ServerAddress))
+ {
+ break;
+ }
+ if (!m_Buffer.ReadBEShort(ServerPort))
+ {
+ break;
+ }
+ if (!m_Buffer.ReadVarInt(NextState))
+ {
+ break;
+ }
m_Buffer.CommitRead();
m_Protocol = new cProtocol172(m_Client, ServerAddress, (UInt16)ServerPort, NextState);
return true;
@@ -991,9 +1000,18 @@ bool cProtocolRecognizer::TryRecognizeLengthedProtocol(UInt32 a_PacketLengthRema
AString ServerAddress;
short ServerPort;
UInt32 NextState;
- m_Buffer.ReadVarUTF8String(ServerAddress);
- m_Buffer.ReadBEShort(ServerPort);
- m_Buffer.ReadVarInt(NextState);
+ if (!m_Buffer.ReadVarUTF8String(ServerAddress))
+ {
+ break;
+ }
+ if (!m_Buffer.ReadBEShort(ServerPort))
+ {
+ break;
+ }
+ if (!m_Buffer.ReadVarInt(NextState))
+ {
+ break;
+ }
m_Buffer.CommitRead();
m_Protocol = new cProtocol176(m_Client, ServerAddress, (UInt16)ServerPort, NextState);
return true;