Make sure to terminate strings correctly.

This commit is contained in:
Henrik Ekblad
2014-07-13 00:02:20 +02:00
parent ef91d9b9cc
commit 767fedca5b
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -37,7 +37,8 @@ char* MyMessage::getString(char *buffer) const {
uint8_t payloadType = miGetPayloadType();
if (payloadType == P_STRING) {
strcpy(buffer, data);
strncpy(buffer, data, miGetLength());
buffer[miGetLength()] = '\0';
return buffer;
} else if (buffer != NULL) {
switch(payloadType) {