summaryrefslogtreecommitdiff
path: root/src/net/messagein.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-05 01:22:22 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-06 01:18:57 +0300
commitbd96cc5bd58dabcff64975c91f12779e593b16fc (patch)
tree2c440ec399ff6446e83585c97e5919d67f801594 /src/net/messagein.cpp
parent2549b4753c78726677583d046fc8841c8f3e3577 (diff)
downloadplus-bd96cc5bd58dabcff64975c91f12779e593b16fc.tar.gz
plus-bd96cc5bd58dabcff64975c91f12779e593b16fc.tar.bz2
plus-bd96cc5bd58dabcff64975c91f12779e593b16fc.tar.xz
plus-bd96cc5bd58dabcff64975c91f12779e593b16fc.zip
Add checking for each packet size after reading and processed.
Diffstat (limited to 'src/net/messagein.cpp')
-rw-r--r--src/net/messagein.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index 92447cde2..0c7f9cb7e 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -47,6 +47,26 @@ MessageIn::MessageIn(const char *const data, const unsigned int length) :
DEBUGLOG("MessageIn");
}
+MessageIn::~MessageIn()
+{
+ if (mLength)
+ {
+ if (mPos != mLength && mPos != 2)
+ {
+ logger->log("Wrong actual or planned inbound packet size!");
+ logger->log(" packet id: %d 0x%x",
+ static_cast<int>(mId),
+ static_cast<int>(mId));
+ logger->log(" planned size: %u", mLength);
+ logger->log(" read size: %u", mPos);
+ }
+ }
+ else
+ {
+ logger->log("Zero packet size: %d", static_cast<int>(mId));
+ }
+}
+
unsigned char MessageIn::readUInt8(const char *const str)
{
unsigned char value = static_cast<unsigned char>(-1);