From d593d1d87bd7da8dc96a787f5bca96682e0e7903 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Tue, 15 Oct 2019 08:27:32 +0200 Subject: [PATCH] Fix crash when uneven string size --- sonoff/support.ino | 2 +- sonoff/xdrv_08_serial_bridge.ino | 2 +- sonoff/xdrv_23_zigbee_9_impl.ino | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sonoff/support.ino b/sonoff/support.ino index 33841cc26..bb6a6aa72 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -835,7 +835,7 @@ void SerialSendRaw(char *codes) int size = strlen(codes); - while (size > 0) { + while (size > 1) { strlcpy(stemp, codes, sizeof(stemp)); code = strtol(stemp, &p, 16); Serial.write(code); diff --git a/sonoff/xdrv_08_serial_bridge.ino b/sonoff/xdrv_08_serial_bridge.ino index 8a0543858..2604bfebf 100644 --- a/sonoff/xdrv_08_serial_bridge.ino +++ b/sonoff/xdrv_08_serial_bridge.ino @@ -126,7 +126,7 @@ void CmndSSerialSend(void) char *codes = RemoveSpace(XdrvMailbox.data); int size = strlen(XdrvMailbox.data); - while (size > 0) { + while (size > 1) { strlcpy(stemp, codes, sizeof(stemp)); code = strtol(stemp, &p, 16); SerialBridgeSerial->write(code); // "AA004566" as hex values diff --git a/sonoff/xdrv_23_zigbee_9_impl.ino b/sonoff/xdrv_23_zigbee_9_impl.ino index 69ae1d12b..32d1e8885 100644 --- a/sonoff/xdrv_23_zigbee_9_impl.ino +++ b/sonoff/xdrv_23_zigbee_9_impl.ino @@ -291,7 +291,7 @@ void CmndZigbeeZNPSend(void) SBuffer buf((size+1)/2); - while (size > 0) { + while (size > 1) { char stemp[3]; strlcpy(stemp, codes, sizeof(stemp)); code = strtol(stemp, nullptr, 16);