Limit payload size to MAX_PAYLOAD_SIZE

This commit is contained in:
tekka007
2016-08-10 12:08:44 +02:00
parent dc99e8a8d4
commit 94348cec1a
+3 -2
View File
@@ -210,9 +210,10 @@ MyMessage& MyMessage::setDestination(uint8_t _destination) {
// Set payload
MyMessage& MyMessage::set(void* value, uint8_t length) {
uint8_t payloadLength = value == NULL ? 0 : min(length, MAX_PAYLOAD);
miSetLength(payloadLength);
miSetPayloadType(P_CUSTOM);
miSetLength(length);
memcpy(data, value, min(length, MAX_PAYLOAD));
memcpy(data, value, payloadLength);
return *this;
}