From e6e23484836d6a611ee9be4118950838b5c5e13e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20M=C3=B6hle?= <91616163+softhack007@users.noreply.github.com> Date: Sun, 25 Jan 2026 17:29:10 +0100 Subject: [PATCH] protect start byte If Channel is less than 0, it's clamped to 0 on line 134. Then on line 138, dmxData[0] is written with the value, overwriting the start byte that was just set on line 137. DMX Channel numbers should be 1-based (1-512). The bounds check should clamp Channel to a minimum of 1, not 0, to prevent corrupting the start byte Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- wled00/src/dependencies/dmx/SparkFunDMX.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/src/dependencies/dmx/SparkFunDMX.cpp b/wled00/src/dependencies/dmx/SparkFunDMX.cpp index b9870e88..1ef12121 100644 --- a/wled00/src/dependencies/dmx/SparkFunDMX.cpp +++ b/wled00/src/dependencies/dmx/SparkFunDMX.cpp @@ -131,7 +131,7 @@ uint8_t SparkFunDMX::read(int Channel) { // Function to send DMX data void SparkFunDMX::write(int Channel, uint8_t value) { - if (Channel < 0) Channel = 0; + if (Channel < 1) Channel = 1; if (Channel+1 > chanSize) chanSize = min(dmxMaxChannel +1, Channel+1); // WLEDMM "+1" as we need to account for start byte if (Channel > dmxMaxChannel) Channel = dmxMaxChannel; // WLEDMM prevent array out-of-bounds access dmxData[0] = 0;