Skip to content

minimal bugfix for DMX-serial out-of-bounds write (#5316 and #6020) - #6021

Merged
softhack007 merged 4 commits into
mainfrom
bugfix_5316
Dec 2, 2026
Merged

softhack007 merged 4 commits into
mainfrom
bugfix_5316

Conversation

@softhack007

@softhack007 softhack007 commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

What it does

only solves the DMX-serial out-of-bounds write and avoids the wrong channel reassignment. See #5316 and #6020 for more information.

AI assistance: no

Checklist

  • I have personally reviewed all changes (incl. source code) before opening this PR.
  • I'm ready to explain my proposed source code changes in detail (without an AI agent answering for me).
  • I agree to follow this project's Code of Conduct.

Summary by CodeRabbit

  • Bug Fixes
    • DMX reads now return zero for channel numbers below 1 or beyond the supported range, instead of using a clamped channel.
    • DMX writes now ignore channel numbers outside the supported range.
    • DMX receiving now reads only when data is available and stops at the maximum channel, avoiding processing unavailable or out-of-range channel data.

only solves the out-of-bounds write, and avoids wrong channel reassignment
@softhack007 softhack007 added the bug label Dec 2, 2026
@softhack007 softhack007 changed the title minimal bugfix for #5316 and #6020 minimal bugfix for DMX-serial out-of-bounds write (#5316 and #6020) Dec 2, 2026
@softhack007

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@softhack007 softhack007 added this to the 16.1 milestone Dec 2, 2026
@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: wled/WLED
  • Branch: bugfix_5316
  • File: .coderabbit.yaml
  • Commit: 2dbbe8a
  • Layers: Repository YAML (base), Repository UI (inherited), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0b74aeab-e5f7-4cb3-9bff-66d6254e381a
Commits

Reviewing files that changed from the base of the PR and between 24fc3db and 2dbbe8a.

Files selected for processing: 1

  • wled00/src/dependencies/dmx/SparkFunDMX.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Recent review details

Context from checks skipped due to timeout: 5

  • GitHub Check: CodeRabbit
  • GitHub Check: Analyze (actions)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (c-cpp)
  • GitHub Check: Analyze (python)
Additional context used

Code guidelines: 3

docs/hardening.instructions.md — configured
docs/cpp.instructions.md — configured
AGENTS.md — configured
Path-based instructions: 5

Apply the WLED security hardening rules from docs/hardening.instructions.md, and consult docs/securecode.instructions.md when more details are needed for actionable recommendations.

CodeRabbit configuration file

Files:

  • wled00/src/dependencies/dmx/SparkFunDMX.cpp
Follow the C++ coding conventions documented in docs/cpp.instructions.md and the general project guidelines in AGENTS.md and .github/copilot-instructions.md.

CodeRabbit configuration file

Files:

  • wled00/src/dependencies/dmx/SparkFunDMX.cpp
Applicability reference: AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference See also: `.github/copilot-instructions.md`, `.github/agent-build.instructions.md`, `docs/cpp.instructions.md`, `docs/web.in...

CodeRabbit inference engine (docs/hardening.instructions.md)

Files:

  • wled00/src/dependencies/dmx/SparkFunDMX.cpp
Source excerpt: Follow the existing style in the file you are editing Source excerpt: Avoid unexplained "magic numbers".

CodeRabbit inference engine (AGENTS.md)

Files:

  • wled00/src/dependencies/dmx/SparkFunDMX.cpp
Source excerpt: PRs should respect `.gitignore` and not upload files like `platformio_override.ini`.

CodeRabbit inference engine (AGENTS.md)

Files:

  • wled00/src/dependencies/dmx/SparkFunDMX.cpp
Learnings: 5

Learning: 2026-12-02T16:50:37.145Z

Learnt from: CR
Repo: wled/WLED PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-12-02T16:50:37.145Z
Learning: Applies to {wled00,usermods}/** : Source excerpt:
# AGENTS.md — WLED AI Coding Agent & AI Code Review Reference

## C++ Code Style (wled00/, usermods/)

### Error Handling

- **No C++ exceptions** — some builds disable them
- Use return codes (`false`, `-1`) and global flags (`errorFlag = ERR_LOW_MEM`)
- Use early returns as guard clauses: `if (!enabled || (strip.isUpdating() && (millis() - last_time < MAX_USERMOD_DELAY))) return;`

Applied to files:

  • wled00/src/dependencies/dmx/SparkFunDMX.cpp
Learning: 2026-10-21T09:53:08.397Z

Learnt from: CR
Repo: wled/WLED PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-10-21T09:53:08.397Z
Learning: Applies to {wled00,usermods}/** : Source excerpt:
# AGENTS.md — WLED AI Coding Agent & AI Code Review Reference

## C++ Code Style (wled00/, usermods/)

### Formatting

- Single-statement `if` bodies may omit braces: `if (a == b) doStuff(a);`

Applied to files:

  • wled00/src/dependencies/dmx/SparkFunDMX.cpp
Learning: 2026-11-03T20:54:00.798Z

Learnt from: CR
Repo: wled/WLED PR: 0
File: docs/cpp.instructions.md:0-0
Timestamp: 2026-11-03T20:54:00.798Z
Learning: Applies to {wled00,usermods}/** : Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
See also: `.github/copilot-instructions.md`, `.github/agent-build.instructions.md`,
`docs/cpp.instructions.md`, `docs/web.instructions.md`, `docs/cicd.instructions.md`,
`docs/hardening.instructions.md`, `docs/securecode.instructions.md`.

AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## C++ Code Style (wled00/, usermods/)
### Debug Output
See docs/cpp.instructions.md section Error Handling for more information.

Source excerpt:
# C++ Coding Conventions

## Formatting

- Single-statement `if` bodies may omit braces: `if (a == b) doStuff(a);`

Applied to files:

  • wled00/src/dependencies/dmx/SparkFunDMX.cpp
Learning: 2026-10-31T16:16:08.536Z

Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:16:08.536Z
Learning: Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:

- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).

Source excerpt:
# Thank you for making WLED better!

## Coding Guidelines

### Code style

#### Comments

Comments should have a space between the delimiting characters (e.g. `//`) and the comment text.
We're gradually adopting this style - don't worry if you see older code without spaces!

Applied to files:

  • wled00/src/dependencies/dmx/SparkFunDMX.cpp
Learning: 2026-10-31T16:16:08.536Z

Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:16:08.536Z
Learning: Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:

- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).

Source excerpt:
# Thank you for making WLED better!

## Coding Guidelines

### Code style

#### Comments

There is no hard character limit for a comment within a line,
though as a rule of thumb consider wrapping after 120 characters.
Inline comments are OK if they describe that line only and are not exceedi...

Applied to files:

  • wled00/src/dependencies/dmx/SparkFunDMX.cpp
Additional comments: 1

wled00/src/dependencies/dmx/SparkFunDMX.cpp: 1

134-134: Security & Privacy

The write guard already keeps every store inside dmxData[0..512]. Under initRead, chanSize is at most 512. Under initWrite, chanSize is at most 513, which admits channel 512 only. Before initialization, chanSize is 0, so no write is accepted. The proposed bound question has the answer "no," and the guard does not need a change.

Walkthrough

DMX reads and writes now reject channels outside their valid ranges. Receive processing reads serial data only while currentChannel is at most dmxMaxChannel.

Changes

DMX Channel Bounds

Layer / File(s) Summary
Validate channel access
wled00/src/dependencies/dmx/SparkFunDMX.cpp
read returns 0 for channels below 1, above chanSize, or above dmxMaxChannel. write ignores channels below 0 or at least chanSize. Receive processing reads data only through dmxMaxChannel.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Possibly related issues

  • wled/WLED issue 6020 — The issue describes DMX output crashes caused by channel allocation errors. The PR changes DMX channel bounds, which relates to the described out-of-bounds write.

Suggested reviewers: lplassman

Merge Risk: Minimal · up to 2dbbe

This change stops DMX channel reads and writes from going outside the valid range and lets a full 512-channel frame complete. I found no remaining merge-blocking risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names a minimal bugfix for a DMX-serial out-of-bounds write and cites issues #5316 and #6020. The change clamps out-of-range channel reads and writes in SparkFunDMX and bounds the receive lo…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names a minimal bugfix for a DMX-serial out-of-bounds write and cites issues #5316 and #6020. The change clamps out-of-range channel reads and writes in SparkFunDMX and bounds the receive loop in update, which addresses that out-of-bounds write. The title is specific and matches the main change. It does not name the files, and the issue references are cited by number only, which is acceptable.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@softhack007 softhack007 added the DMX or Art-Net related to DMX, E1.31 or Art-Net (need special hardware) label Dec 2, 2026
@coderabbitai

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as resolved.

@softhack007
softhack007 merged commit 0d48575 into main Dec 2, 2026
66 checks passed
@softhack007
softhack007 deleted the bugfix_5316 branch December 2, 2026 20:03
softhack007 added a commit that referenced this pull request Dec 2, 2026
…6021)

only solves the out-of-bounds write, and avoids wrong channel reassignment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug DMX or Art-Net related to DMX, E1.31 or Art-Net (need special hardware)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

minimal fix for #5316 (DMX out crash due to errors in channel allocation logic)

1 participant