mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
use strlcpy for readCommand
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user