@@ -74,15 +74,17 @@ inline void transportProcess() {
74
74
(void )signerCheckTimer (); // Manage signing timeout
75
75
#endif
76
76
77
- uint8_t len = transportReceive ((uint8_t *)&_msg);
78
- (void )len ; // until somebody makes use of 'len'
77
+ uint8_t payloadLength = transportReceive ((uint8_t *)&_msg);
78
+ (void )payloadLength ; // until somebody makes use of it
79
79
ledBlinkRx (1 );
80
80
81
+
81
82
uint8_t command = mGetCommand (_msg);
82
83
uint8_t type = _msg.type ;
83
84
uint8_t sender = _msg.sender ;
84
85
uint8_t last = _msg.last ;
85
86
uint8_t destination = _msg.destination ;
87
+
86
88
87
89
#ifdef MY_SIGNING_FEATURE
88
90
// Before processing message, reject unsigned messages if signing is required and check signature (if it is signed and addressed to us)
@@ -137,7 +139,11 @@ inline void transportProcess() {
137
139
if (destination == _nc.nodeId ) {
138
140
// This message is addressed to this node
139
141
mSetSigned (_msg,0 ); // Clear the sign-flag now as verification is completed
140
-
142
+ // prevent buffer overflow by limiting max. possible message length (5 bits=31 bytes max) to MAX_PAYLOAD (25 bytes)
143
+ mSetLength (_msg, min (mGetLength (_msg),MAX_PAYLOAD));
144
+ // null terminate data
145
+ _msg.data [mGetLength (_msg)] = 0x00 ;
146
+
141
147
#if defined(MY_REPEATER_FEATURE)
142
148
if (_msg.last != _nc.parentNodeId ) {
143
149
// Message is from one of the child nodes. Add it to routing table.
0 commit comments