Null termination issue, Fixes #322

This commit is contained in:
tekka007
2016-01-05 12:36:24 +01:00
parent 7ee39509eb
commit 39407e4ae4
+4 -3
View File
@@ -203,10 +203,11 @@ MyMessage& MyMessage::set(const char* value) {
uint8_t length = value == NULL ? 0 : min(strlen(value), MAX_PAYLOAD);
miSetLength(length);
miSetPayloadType(P_STRING);
if (length)
if (length) {
strncpy(data, value, length);
else
data[0] ='\0';
}
// null terminate string
data[length] = 0;
return *this;
}