Skip to content
Snippets Groups Projects
Verified Commit 6b6fda85 authored by Anian Bühler's avatar Anian Bühler
Browse files

Fixed buffer overflow by unreadable data

parent 005bbe30
No related branches found
No related tags found
1 merge request!10Dev verbose
...@@ -130,9 +130,7 @@ bool DidacticPSNet::recieveData() ...@@ -130,9 +130,7 @@ bool DidacticPSNet::recieveData()
static int msgCounter = 0; static int msgCounter = 0;
static int topicCounter = 0; static int topicCounter = 0;
static int payloadCounter = 0; static int payloadCounter = 0;
// if(msgCounter == NULL){ msgCounter = 0; }
// if(topicCounter == NULL){ topicCounter = 0; }
// if(dataCounter == NULL){ dataCounter = 0; }
while (checkData()) while (checkData())
{ {
char localBuffer = _port->read(); char localBuffer = _port->read();
...@@ -159,8 +157,16 @@ bool DidacticPSNet::recieveData() ...@@ -159,8 +157,16 @@ bool DidacticPSNet::recieveData()
} }
else if (_readBufferMessage[0] == MSG_PRELIMITER && localBuffer != MSG_DELIMITER) else if (_readBufferMessage[0] == MSG_PRELIMITER && localBuffer != MSG_DELIMITER)
{ {
msgCounter++; if (msgCounter > LEN_OVERHEAD + MAX_LEN_TOPICS + MAX_LEN_PAYLOAD)
_readBufferMessage[msgCounter] = localBuffer; {
msgCounter == 0;
_readBufferMessage[0] = '\0';
}
else
{
msgCounter++;
_readBufferMessage[msgCounter] = localBuffer;
}
} }
} }
return false; return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment