Fix string length problem reported by EasyIoT
This commit is contained in:
@@ -177,10 +177,10 @@ MyMessage& MyMessage::set(void* value, uint8_t length) {
|
|||||||
|
|
||||||
|
|
||||||
MyMessage& MyMessage::set(const char* value) {
|
MyMessage& MyMessage::set(const char* value) {
|
||||||
uint8_t length = strlen(value);
|
uint8_t length = min(strlen(value), MAX_PAYLOAD);
|
||||||
miSetLength(length);
|
miSetLength(length);
|
||||||
miSetPayloadType(P_STRING);
|
miSetPayloadType(P_STRING);
|
||||||
strncpy(data, value, min(length, MAX_PAYLOAD));
|
strncpy(data, value, length);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user