Commit f5a00d8b authored by Julius Roob's avatar Julius Roob 🐛 Committed by Bernd Lietzow

common: add buffer size checks to message factory

Adds buffer size checks to handle messages smaller than the minimum
message header in a sane manner.
parent 36c93a9f
......@@ -12,10 +12,12 @@
NetMessage* AbstractNetMessageFactory::createFromBuf(char* recvBuf, size_t bufLen)
if(unlikely(bufLen < NETMSG_MIN_LENGTH))
return new SimpleMsg(NETMSGTYPE_Invalid);
NetMessageHeader header;
// decode the message header
NetMessage::deserializeHeader(recvBuf, bufLen, &header);
// delegate the rest of the work to another method...
......@@ -117,6 +117,8 @@ class NetMessage
Deserializer des(buf, bufLen);
des % *outHeader;
outHeader->msgType = NETMSGTYPE_Invalid;
class ResponseContext
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment