Merge pull request #317 from tekka007/nullTerminationFix

Fix null termination issue
This commit is contained in:
Henrik Ekblad
2016-01-02 11:33:59 +01:00
+8 -2
View File
@@ -74,16 +74,18 @@ inline void transportProcess() {
(void)signerCheckTimer(); // Manage signing timeout (void)signerCheckTimer(); // Manage signing timeout
#endif #endif
uint8_t len = transportReceive((uint8_t *)&_msg); uint8_t payloadLength = transportReceive((uint8_t *)&_msg);
(void)len; //until somebody makes use of 'len' (void)payloadLength; //until somebody makes use of it
ledBlinkRx(1); ledBlinkRx(1);
uint8_t command = mGetCommand(_msg); uint8_t command = mGetCommand(_msg);
uint8_t type = _msg.type; uint8_t type = _msg.type;
uint8_t sender = _msg.sender; uint8_t sender = _msg.sender;
uint8_t last = _msg.last; uint8_t last = _msg.last;
uint8_t destination = _msg.destination; uint8_t destination = _msg.destination;
#ifdef MY_SIGNING_FEATURE #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) // Before processing message, reject unsigned messages if signing is required and check signature (if it is signed and addressed to us)
// Note that we do not care at all about any signature found if we do not require signing, nor do we care about ACKs (they are never signed) // Note that we do not care at all about any signature found if we do not require signing, nor do we care about ACKs (they are never signed)
@@ -137,6 +139,10 @@ inline void transportProcess() {
if (destination == _nc.nodeId) { if (destination == _nc.nodeId) {
// This message is addressed to this node // This message is addressed to this node
mSetSigned(_msg,0); // Clear the sign-flag now as verification is completed mSetSigned(_msg,0); // Clear the sign-flag now as verification is completed
// prevent buffer overflow by limiting max. possible message length (5 bits=31 bytes max) to MAX_PAYLOAD (25 bytes)
mSetLength(_msg, min(mGetLength(_msg),MAX_PAYLOAD));
// null terminate data
_msg.data[mGetLength(_msg)] = 0x00;
#if defined(MY_REPEATER_FEATURE) #if defined(MY_REPEATER_FEATURE)
if (_msg.last != _nc.parentNodeId) { if (_msg.last != _nc.parentNodeId) {