Fix payload length verification (#680)
This commit is contained in:
committed by
Patrick Fallberg
parent
f59be0aa2a
commit
fdbb285dee
@@ -554,11 +554,16 @@ void transportProcessMessage(void) {
|
|||||||
(void)signerCheckTimer();
|
(void)signerCheckTimer();
|
||||||
// receive message
|
// receive message
|
||||||
setIndication(INDICATION_RX);
|
setIndication(INDICATION_RX);
|
||||||
const uint8_t payloadLength = transportReceive((uint8_t *)&_msg);
|
uint8_t payloadLength = transportReceive((uint8_t *)&_msg);
|
||||||
// get message length and limit size
|
// get message length and limit size
|
||||||
|
|
||||||
const uint8_t msgLength = min(mGetLength(_msg), (uint8_t)MAX_PAYLOAD);
|
const uint8_t msgLength = min(mGetLength(_msg), (uint8_t)MAX_PAYLOAD);
|
||||||
// calculate expected length
|
// calculate expected length
|
||||||
const uint8_t expectedMessageLength = HEADER_SIZE + (mGetSigned(_msg) ? MAX_PAYLOAD : msgLength);
|
const uint8_t expectedMessageLength = HEADER_SIZE + (mGetSigned(_msg) ? MAX_PAYLOAD : msgLength);
|
||||||
|
#if defined(MY_RF24_ENABLE_ENCRYPTION)
|
||||||
|
// payload length = a multiple of blocksize length for decrypted messages, i.e. cannot be used for payload length check
|
||||||
|
payloadLength = expectedMessageLength;
|
||||||
|
#endif
|
||||||
const uint8_t command = mGetCommand(_msg);
|
const uint8_t command = mGetCommand(_msg);
|
||||||
const uint8_t type = _msg.type;
|
const uint8_t type = _msg.type;
|
||||||
const uint8_t sender = _msg.sender;
|
const uint8_t sender = _msg.sender;
|
||||||
|
|||||||
@@ -141,7 +141,9 @@ uint8_t transportReceive(void* data)
|
|||||||
// has to be adjusted, WIP!
|
// has to be adjusted, WIP!
|
||||||
_aes.set_IV(0);
|
_aes.set_IV(0);
|
||||||
// decrypt data
|
// decrypt data
|
||||||
_aes.cbc_decrypt((byte*)(data), (byte*)(data), len>16?2:1);
|
if (_aes.cbc_decrypt((uint8_t*)(data), (uint8_t*)(data), len > 16 ? 2 : 1) != AES_SUCCESS) {
|
||||||
|
len = 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user