Fix payload null termination issue

This commit is contained in:
tekka007
2015-12-31 11:37:37 +01:00
parent f895bbab54
commit 5e5b06aa28
+8 -3
View File
@@ -74,15 +74,18 @@ inline void transportProcess() {
(void)signerCheckTimer(); // Manage signing timeout
#endif
uint8_t len = transportReceive((uint8_t *)&_msg);
(void)len; //until somebody makes use of 'len'
uint8_t payloadLength = transportReceive((uint8_t *)&_msg);
(void)payloadLength; //until somebody makes use of it
ledBlinkRx(1);
uint8_t command = mGetCommand(_msg);
// prevent buffer overflow by limiting message length (5 bits=31 bytes max) to MAX_PAYLOAD (25 bytes)
uint8_t messageLength = min(mGetLength(_msg),MAX_PAYLOAD);
uint8_t type = _msg.type;
uint8_t sender = _msg.sender;
uint8_t last = _msg.last;
uint8_t destination = _msg.destination;
#ifdef MY_SIGNING_FEATURE
// Before processing message, reject unsigned messages if signing is required and check signature (if it is signed and addressed to us)
@@ -137,7 +140,9 @@ inline void transportProcess() {
if (destination == _nc.nodeId) {
// This message is addressed to this node
mSetSigned(_msg,0); // Clear the sign-flag now as verification is completed
// clear bytes after message end
memset((uint8_t*)&_msg.data[messageLength],0x00,MAX_PAYLOAD-messageLength);
#if defined(MY_REPEATER_FEATURE)
if (_msg.last != _nc.parentNodeId) {
// Message is from one of the child nodes. Add it to routing table.