Merge pull request #6646 from s-hadinger/fix_parse

Fix crash when uneven string size
This commit is contained in:
Theo Arends 2019-10-15 09:28:47 +02:00 committed by GitHub
commit 67bbd15612
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -835,7 +835,7 @@ void SerialSendRaw(char *codes)
int size = strlen(codes); int size = strlen(codes);
while (size > 0) { while (size > 1) {
strlcpy(stemp, codes, sizeof(stemp)); strlcpy(stemp, codes, sizeof(stemp));
code = strtol(stemp, &p, 16); code = strtol(stemp, &p, 16);
Serial.write(code); Serial.write(code);

View File

@ -126,7 +126,7 @@ void CmndSSerialSend(void)
char *codes = RemoveSpace(XdrvMailbox.data); char *codes = RemoveSpace(XdrvMailbox.data);
int size = strlen(XdrvMailbox.data); int size = strlen(XdrvMailbox.data);
while (size > 0) { while (size > 1) {
strlcpy(stemp, codes, sizeof(stemp)); strlcpy(stemp, codes, sizeof(stemp));
code = strtol(stemp, &p, 16); code = strtol(stemp, &p, 16);
SerialBridgeSerial->write(code); // "AA004566" as hex values SerialBridgeSerial->write(code); // "AA004566" as hex values

View File

@ -291,7 +291,7 @@ void CmndZigbeeZNPSend(void)
SBuffer buf((size+1)/2); SBuffer buf((size+1)/2);
while (size > 0) { while (size > 1) {
char stemp[3]; char stemp[3];
strlcpy(stemp, codes, sizeof(stemp)); strlcpy(stemp, codes, sizeof(stemp));
code = strtol(stemp, nullptr, 16); code = strtol(stemp, nullptr, 16);