From 61e9e8a361954e0301dde5d0f02db07caa83dd48 Mon Sep 17 00:00:00 2001 From: Daddelgreis <47208852+Daddelgreis74@users.noreply.github.com> Date: Mon, 25 Feb 2019 17:56:53 +0100 Subject: [PATCH 1/3] GPIO_LED1 change GPIO_LED1 to GPIO_LED1_INV right attitude --- sonoff/sonoff_template.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonoff/sonoff_template.h b/sonoff/sonoff_template.h index 462ec3b3f..c839d2a7e 100644 --- a/sonoff/sonoff_template.h +++ b/sonoff/sonoff_template.h @@ -1764,7 +1764,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = { 0, // GPIO09 (SD_DATA2 Flash QIO or ESP8285) 0, // GPIO10 (SD_DATA3 Flash QIO or ESP8285) // GPIO11 (SD_CMD Flash) - GPIO_LED1, // GPIO12 Green LED - Link status + GPIO_LED1_INV, // GPIO12 Green LED - Link status GPIO_LED2, // GPIO13 Red LED - Power status 0, 0, 0, 0 }, From 9f00978a799e3e286be339ab6344da3c307a87a7 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 25 Feb 2019 19:47:45 +0100 Subject: [PATCH 2/3] Fix Domoticz Color regression Fix Domoticz Color regression (#5310 ) --- sonoff/sonoff.ino | 7 +++---- sonoff/xdrv_04_light.ino | 21 ++++++++++----------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 2c771a8ab..b19841177 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -789,8 +789,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len) param_low = 1; param_high = 250; break; - - case P_RGB_REMAP: + case P_RGB_REMAP: param_low = 0; param_high = 119; break; @@ -798,8 +797,8 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len) if ((payload >= param_low) && (payload <= param_high)) { Settings.param[pindex] = payload; switch (pindex) { - case P_RGB_REMAP: - LightUpdateColorMapping(); + case P_RGB_REMAP: + LightUpdateColorMapping(); break; } } diff --git a/sonoff/xdrv_04_light.ino b/sonoff/xdrv_04_light.ino index c606425b4..f5b1a88bc 100644 --- a/sonoff/xdrv_04_light.ino +++ b/sonoff/xdrv_04_light.ino @@ -86,8 +86,6 @@ struct LCwColor { #define MAX_FIXED_COLD_WARM 4 const LCwColor kFixedColdWarm[MAX_FIXED_COLD_WARM] PROGMEM = { 0,0, 255,0, 0,255, 128,128 }; -uint8_t color_remap[5]; - uint8_t ledTable[] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -111,6 +109,7 @@ uint8_t light_current_color[5]; uint8_t light_new_color[5]; uint8_t light_last_color[5]; uint8_t light_signal_color[5]; +uint8_t light_color_remap[5]; uint8_t light_wheel = 0; uint8_t light_subtype = 0; @@ -576,25 +575,25 @@ void LightUpdateColorMapping(void) param = 119; } uint8_t tmp[] = {0,1,2,3,4}; - color_remap[0] = tmp[param / 24]; + light_color_remap[0] = tmp[param / 24]; for (uint8_t i = param / 24; i<4; ++i){ tmp[i] = tmp[i+1]; } param = param % 24; - color_remap[1] = tmp[(param / 6)]; + light_color_remap[1] = tmp[(param / 6)]; for (uint8_t i = param / 6; i<3; ++i){ tmp[i] = tmp[i+1]; } param = param % 6; - color_remap[2] = tmp[(param / 2)]; + light_color_remap[2] = tmp[(param / 2)]; for (uint8_t i = param / 2; i<2; ++i){ tmp[i] = tmp[i+1]; } param = param % 2; - color_remap[3] = tmp[param]; - color_remap[4] = tmp[1-param]; + light_color_remap[3] = tmp[param]; + light_color_remap[4] = tmp[1-param]; - //snprintf_P(log_data, sizeof(log_data), "%d colors: %d %d %d %d %d",Settings.param[P_RGB_REMAP], color_remap[0],color_remap[1],color_remap[2],color_remap[3],color_remap[4]); + //snprintf_P(log_data, sizeof(log_data), "%d colors: %d %d %d %d %d",Settings.param[P_RGB_REMAP], light_color_remap[0],light_color_remap[1],light_color_remap[2],light_color_remap[3],light_color_remap[4]); //AddLog(LOG_LEVEL_DEBUG); } @@ -929,11 +928,11 @@ void LightAnimate(void) } } else { -#ifdef PWM_LIGHTSCHEME0_IGNORE_SLEEP +#ifdef PWM_LIGHTSCHEME0_IGNORE_SLEEP sleep = (LS_POWER == Settings.light_scheme) ? Settings.sleep : 0; // If no animation then use sleep as is #else sleep = 0; -#endif // PWM_LIGHTSCHEME0_IGNORE_SLEEP +#endif // PWM_LIGHTSCHEME0_IGNORE_SLEEP switch (Settings.light_scheme) { case LS_POWER: LightSetDimmer(Settings.light_dimmer); @@ -1001,7 +1000,7 @@ void LightAnimate(void) uint8_t orig_col[5]; memcpy(orig_col, cur_col, sizeof(orig_col)); for (uint8_t i = 0; i < 5; i++) { - cur_col[i] = orig_col[color_remap[i]]; + cur_col[i] = orig_col[light_color_remap[i]]; } for (uint8_t i = 0; i < light_subtype; i++) { From 9a670be95b20868d6ca257009e1d3df1a4f24881 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 25 Feb 2019 21:23:18 +0100 Subject: [PATCH 3/3] Fix buffer overflow Fix buffer overflow (#5310) --- sonoff/xdrv_04_light.ino | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sonoff/xdrv_04_light.ino b/sonoff/xdrv_04_light.ino index f5b1a88bc..0594a5a09 100644 --- a/sonoff/xdrv_04_light.ino +++ b/sonoff/xdrv_04_light.ino @@ -1252,7 +1252,11 @@ bool LightColorEntry(char *buffer, uint8_t buffer_length) entry_type = 2; // Decimal } else if (((2 * light_subtype) == buffer_length) || (buffer_length > 3)) { // Hexadecimal entry - for (uint8_t i = 0; i < buffer_length / 2; i++) { + uint8_t limit = buffer_length / 2; + if (limit > sizeof(light_entry_color)) { // Fix buffer overflow due to too many parameters + limit = sizeof(light_entry_color); + } + for (uint8_t i = 0; i < limit; i++) { strlcpy(scolor, buffer + (i *2), 3); light_entry_color[i] = (uint8_t)strtol(scolor, &p, 16); }