From 371c4e00511765e930aab1967f94dbb719a9946a Mon Sep 17 00:00:00 2001 From: cschwinne Date: Thu, 20 May 2021 21:41:39 +0200 Subject: [PATCH] Fixed WS281x output on ESP32 Fixed potential out-of-bounds write in MQTT Fixed IR pin not changeable if IR disabled Fixed XML API containing -1 on Manual only RGBW mode (see #888, #1783) --- CHANGELOG.md | 7 +++++++ wled00/bus_wrapper.h | 6 +++--- wled00/cfg.cpp | 4 ---- wled00/mqtt.cpp | 2 +- wled00/set.cpp | 4 ---- wled00/wled.h | 8 ++++++-- wled00/xml.cpp | 2 +- 7 files changed, 18 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c04cdae8..56c722e22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ ### Builds after release 0.12.0 +#### Build 2105200 + +- Fixed WS281x output on ESP32 +- Fixed potential out-of-bounds write in MQTT +- Fixed IR pin not changeable if IR disabled +- Fixed XML API containing -1 on Manual only RGBW mode (see #888, #1783) + #### Build 2105171 - Always copy MQTT payloads to prevent non-0-terminated strings diff --git a/wled00/bus_wrapper.h b/wled00/bus_wrapper.h index e8e6fc654..e5e5db54c 100644 --- a/wled00/bus_wrapper.h +++ b/wled00/bus_wrapper.h @@ -837,7 +837,7 @@ class PolyBus { } //gives back the internal type index (I_XX_XXX_X above) for the input - static uint8_t getI(uint8_t busType, uint8_t* pins, uint8_t num = 0, bool rgbwOverride = false) { + static uint8_t getI(uint8_t busType, uint8_t* pins, uint8_t num = 0) { if (!IS_DIGITAL(busType)) return I_NONE; if (IS_2PIN(busType)) { //SPI LED chips bool isHSPI = false; @@ -863,7 +863,7 @@ class PolyBus { switch (busType) { case TYPE_WS2812_RGB: case TYPE_WS2812_WWA: - return (rgbwOverride ? I_8266_U0_NEO_4 : I_8266_U0_NEO_3) + offset; + return I_8266_U0_NEO_3 + offset; case TYPE_SK6812_RGBW: return I_8266_U0_NEO_4 + offset; case TYPE_WS2811_400KHZ: @@ -877,7 +877,7 @@ class PolyBus { switch (busType) { case TYPE_WS2812_RGB: case TYPE_WS2812_WWA: - return (rgbwOverride ? I_32_R0_NEO_3 : I_32_R0_NEO_4) + offset; + return I_32_R0_NEO_3 + offset; case TYPE_SK6812_RGBW: return I_32_R0_NEO_4 + offset; case TYPE_WS2811_400KHZ: diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 1b94c00ff..d6aede4e5 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -140,7 +140,6 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { CJSON(macroLongPress,hw_btn_ins_0_macros[1]); CJSON(macroDoublePress, hw_btn_ins_0_macros[2]); - #ifndef WLED_DISABLE_INFRARED int hw_ir_pin = hw["ir"]["pin"] | -2; // 4 if (hw_ir_pin > -2) { if (pinManager.allocatePin(hw_ir_pin,false)) { @@ -149,7 +148,6 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { irPin = -1; } } - #endif CJSON(irEnabled, hw["ir"]["type"]); JsonObject relay = hw[F("relay")]; @@ -508,11 +506,9 @@ void serializeConfig() { hw_btn_ins_0_macros.add(macroLongPress); hw_btn_ins_0_macros.add(macroDoublePress); - #ifndef WLED_DISABLE_INFRARED JsonObject hw_ir = hw.createNestedObject("ir"); hw_ir["pin"] = irPin; hw_ir[F("type")] = irEnabled; // the byte 'irEnabled' does contain the IR-Remote Type ( 0=disabled ) - #endif JsonObject hw_relay = hw.createNestedObject(F("relay")); hw_relay["pin"] = rlyPin; diff --git a/wled00/mqtt.cpp b/wled00/mqtt.cpp index 23a1bd039..79de0afb8 100644 --- a/wled00/mqtt.cpp +++ b/wled00/mqtt.cpp @@ -64,9 +64,9 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties } //make a copy of the payload to 0-terminate it char* payloadStr = new char[len+1]; + if (payloadStr == nullptr) return; //no mem strncpy(payloadStr, payload, len); payloadStr[len] = '\0'; - if (payloadStr == nullptr) return; //no mem DEBUG_PRINTLN(payloadStr); size_t topicPrefixLen = strlen(mqttDeviceTopic); diff --git a/wled00/set.cpp b/wled00/set.cpp index 05de14257..ee6e102a7 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -78,9 +78,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) int t = 0; if (rlyPin>=0 && pinManager.isPinAllocated(rlyPin)) pinManager.deallocatePin(rlyPin); - #ifndef WLED_DISABLE_INFRARED if (irPin>=0 && pinManager.isPinAllocated(irPin)) pinManager.deallocatePin(irPin); - #endif if (btnPin>=0 && pinManager.isPinAllocated(btnPin)) pinManager.deallocatePin(btnPin); //TODO remove all busses, but not in this system call //busses->removeAll(); @@ -128,14 +126,12 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) if (t > 0 && t <= MAX_LEDS) ledCount = t; // upate other pins - #ifndef WLED_DISABLE_INFRARED int hw_ir_pin = request->arg(F("IR")).toInt(); if (pinManager.isPinOk(hw_ir_pin) && pinManager.allocatePin(hw_ir_pin,false)) { irPin = hw_ir_pin; } else { irPin = -1; } - #endif int hw_rly_pin = request->arg(F("RL")).toInt(); if (pinManager.allocatePin(hw_rly_pin,true)) { diff --git a/wled00/wled.h b/wled00/wled.h index 0c12231c5..33d7ab228 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2105171 +#define VERSION 2105200 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG @@ -204,7 +204,11 @@ WLED_GLOBAL bool rlyMde _INIT(true); WLED_GLOBAL bool rlyMde _INIT(RLYMDE); #endif #ifndef IRPIN -WLED_GLOBAL int8_t irPin _INIT(4); + #ifdef WLED_DISABLE_INFRARED + WLED_GLOBAL int8_t irPin _INIT(-1); + #else + WLED_GLOBAL int8_t irPin _INIT(4); + #endif #else WLED_GLOBAL int8_t irPin _INIT(IRPIN); #endif diff --git a/wled00/xml.cpp b/wled00/xml.cpp index 03336bd71..c56f1c678 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -51,7 +51,7 @@ void XML_response(AsyncWebServerRequest *request, char* dest) oappend(SET_F("")); oappendi(effectPalette); oappend(SET_F("")); - if (strip.rgbwMode) { + if (strip.isRgbw) { oappendi(col[3]); } else { oappend("-1");