Skip to content

16_x less restrictive DDP header acceptance & bugfix#5554

Merged
DedeHai merged 1 commit intowled:16_xfrom
DedeHai:0_16_DDP_relaxation
May 1, 2026
Merged

16_x less restrictive DDP header acceptance & bugfix#5554
DedeHai merged 1 commit intowled:16_xfrom
DedeHai:0_16_DDP_relaxation

Conversation

@DedeHai
Copy link
Copy Markdown
Collaborator

@DedeHai DedeHai commented May 1, 2026

this is basically the same as #5547 but with the uncertain buffer checks for e131 packets removed

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved packet length validation and safety checks for DDP protocol handling to prevent out-of-bounds reads.
    • Enhanced E1.31/Art-Net packet validation with stricter length checks and better error handling.
    • Added filtering to reject invalid control, status, and configuration packets.
  • Improvements

    • Improved color type compatibility by accepting unsupported types and defaulting to RGB channel layout.
    • Clarified DDP sequence number handling in protocol documentation.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 1, 2026

Walkthrough

This PR adds packet length validation throughout the E1.31/DDP protocol handling pipeline. It propagates the incoming UDP packet length from the async parser through the callback chain and handler signature, uses it to validate DDP packet structure and filter unsupported packet types, changes color type handling to accept all data types by defaulting to RGB, and tightens DMX channel validation.

Changes

Cohort / File(s) Summary
Packet Length Parameter Integration
wled00/fcn_declare.h, wled00/src/dependencies/e131/ESPAsyncE131.h, wled00/src/dependencies/e131/ESPAsyncE131.cpp, wled00/ws.cpp
Adds size_t packetLen parameter throughout the E1.31 packet handling call chain: updates the callback function type signature, propagates packet length from the async parser to the handler, and passes remaining payload size to handleE131Packet for protocol processing.
DDP Protocol Validation & Filtering
wled00/e131.cpp
Implements length-based safety checks (early return if packet too short for header, rejection if actual length cannot satisfy header/data expectations), expands DDP packet type filtering (drops control/status/config and query/reply packets, rejects storage unless PUSH flag set), changes color type handling to accept all data types with RGB default instead of rejecting unsupported types, and tightens E1.31/Art-Net entry validation including minimum-length check for Art-Net and stricter DMX channel count validation.
DDP Documentation & Sequence Handling
wled00/data/common.js, wled00/udp.cpp
Clarifies that DDP byte 2's lower nibble represents sequence number (where 0 disables checking), and adds TODO comment documenting sequence number valid range (1–15) with 0 reserved as unused.

Sequence Diagram(s)

sequenceDiagram
    participant Client as UDP/WebSocket Client
    participant Parser as ESPAsyncE131 Parser
    participant Handler as handleE131Packet
    participant DDP as DDP Processor

    Client->>Parser: Send packet (payload + length)
    Parser->>Parser: Capture packet length
    Note over Parser: Validate min length for E1.31/Art-Net<br/>before ACN ID check
    Parser->>Handler: Dispatch callback(packet, IP, protocol, packetLen)
    
    Handler->>Handler: Receive packetLen parameter
    alt Protocol is DDP
        Handler->>DDP: Process with packetLen
        DDP->>DDP: Validate header length
        DDP->>DDP: Check if actual length satisfies<br/>header + data expectations
        DDP->>DDP: Filter packet types<br/>(drop control/status/config/query)
        DDP->>DDP: Resolve color type<br/>(accept unknown, default to RGB)
        DDP->>DDP: Render pixels if PUSH flag set
    else Protocol is E1.31
        Handler->>Handler: Validate DMX channel count > 0
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Possibly related PRs

Suggested labels

connectivity

Suggested reviewers

  • willmmiles
  • blazoncek
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.
Title check ✅ Passed The title 'less restrictive DDP header acceptance & bugfix' accurately describes the main changes: DDP protocol is less restrictive and a bugfix is included, which aligns with the core modifications across e131.cpp, fcn_declare.h, ESPAsyncE131 files, and related handlers.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@DedeHai
Copy link
Copy Markdown
Collaborator Author

DedeHai commented May 1, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 1, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot added the connectivity Issue regarding protocols, WiFi connection or availability of interfaces label May 1, 2026
@DedeHai DedeHai changed the title less restrictive DDP header acceptance & bugfix 16_x less restrictive DDP header acceptance & bugfix May 1, 2026
@DedeHai DedeHai added this to the 16.0.0 beta milestone May 1, 2026
Copy link
Copy Markdown
Member

@softhack007 softhack007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

@DedeHai DedeHai merged commit 9fdd487 into wled:16_x May 1, 2026
25 checks passed
@DedeHai DedeHai deleted the 0_16_DDP_relaxation branch May 1, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

connectivity Issue regarding protocols, WiFi connection or availability of interfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants