use strlcpy for readCommand

This commit is contained in:
proddy
2024-10-21 20:44:57 +02:00
parent 697daeeefd
commit c6c4a5bfb7

View File

@@ -2019,14 +2019,11 @@ bool System::uploadFirmwareURL(const char * url) {
bool System::readCommand(const char * data) { bool System::readCommand(const char * data) {
// extract <deviceID> <type ID> [offset] [length] from string // extract <deviceID> <type ID> [offset] [length] from string
char * p; char * p;
char value[10] = {0}; // null just in case char value[6];
// make a copy so we can iterate // make a copy so we can iterate, max 15 chars (XX XXXX XX XX)
char data_args[EMS_MAX_TELEGRAM_LENGTH]; char data_args[15];
for (uint8_t i = 0; i < strlen(data); i++) { strlcpy(data_args, data, sizeof(data_args));
data_args[i] = data[i];
}
data_args[strlen(data)] = '\0'; // make sure its terminated
uint8_t device_id = 0; // is in hex uint8_t device_id = 0; // is in hex
uint16_t type_id = 0; // is in hex uint16_t type_id = 0; // is in hex