Skip to content

Router: size the fit check from the decoded Data#11018

Merged
thebentern merged 1 commit into
developfrom
decode-size
Jul 16, 2026
Merged

Router: size the fit check from the decoded Data#11018
thebentern merged 1 commit into
developfrom
decode-size

Conversation

@caveman99

@caveman99 caveman99 commented Jul 16, 2026

Copy link
Copy Markdown
Member

The receive-side fit check sized the raw wire Data, while the sender's signedDataFits() sizes the encoded struct. Fields skipped at decode make the two disagree. Size p->decoded on both sides so the gates stay symmetric.

note: this probably affects #10967

Summary by CodeRabbit

  • Bug Fixes

    • Improved validation of signed and unsigned broadcasts to make downgrade decisions more accurate.
    • Packets containing unknown fields are now evaluated correctly without affecting decoded message data.
    • Unsigned broadcasts from recognized signers are properly rejected when they exceed the supported signed format size.
    • Valid broadcasts from non-signers continue to be accepted and delivered as expected.
  • Tests

    • Added coverage for packet compatibility and signing-policy edge cases.

@caveman99
caveman99 requested a review from thebentern July 16, 2026 12:40
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 527659a5-0f6a-4bb7-93df-c8c90b27d67a

📥 Commits

Reviewing files that changed from the base of the PR and between deea7be and bd4ca90.

📒 Files selected for processing (3)
  • src/mesh/Router.cpp
  • src/mesh/Router.h
  • test/test_packet_signing/test_main.cpp

📝 Walkthrough

Walkthrough

Changes

XEdDSA receive-policy flow

Layer / File(s) Summary
Canonical downgrade sizing
src/mesh/Router.h, src/mesh/Router.cpp
The policy API removes the external encoded-size argument and uses canonical protobuf re-encoding of p->decoded for unsigned-broadcast fit validation.
Pre-merge receive-policy validation
src/mesh/Router.cpp
perhapsDecode applies the XEdDSA policy before merging the wire want_response bitfield.
Unknown-field regression coverage
test/test_packet_signing/test_main.cpp
New helpers and A10/A11 tests cover encrypted packets with unknown fields, signer-based dropping, non-signer acceptance, and test registration; nearby comments are updated.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant perhapsDecode
  participant checkXeddsaReceivePolicy
  participant pb_get_encoded_size
  perhapsDecode->>checkXeddsaReceivePolicy: validate decoded packet
  checkXeddsaReceivePolicy->>pb_get_encoded_size: encode-size p->decoded
  pb_get_encoded_size-->>checkXeddsaReceivePolicy: canonical size
  checkXeddsaReceivePolicy-->>perhapsDecode: accept or drop
  perhapsDecode->>perhapsDecode: merge want_response bitfield
Loading

Suggested reviewers: jp-bennett, thebentern, nomdetom

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is on-topic but largely incomplete versus the template; it lacks the required attestations and testing/regression details. Replace the brief note with a fuller PR summary and complete the attestations/testing checklist, including devices tested and any regression notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: sizing the router fit check from decoded Data.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch decode-size

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.

@github-actions

Copy link
Copy Markdown
Contributor

⚡ Try this PR in the Web Flasher

Note

Building this pull request… the flash button, badges and supported-board
list will appear here automatically once CI finishes.

@caveman99 caveman99 added bugfix Pull request that fixes bugs bug Something isn't working triaged Reviewed by the team, has enough information and ready to work on now. labels Jul 16, 2026
@thebentern
thebentern merged commit f52d775 into develop Jul 16, 2026
104 of 106 checks passed
@caveman99
caveman99 deleted the decode-size branch July 16, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working bugfix Pull request that fixes bugs triaged Reviewed by the team, has enough information and ready to work on now.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants