Skip to content

Bound CommonCLI replies at the 157 bytes every caller can give (iteration branch) - #26

Open
ptr727 wants to merge 1 commit into
devfrom
work/cli-reply-bound
Open

ptr727 wants to merge 1 commit into
devfrom
work/cli-reply-bound

Conversation

@ptr727

@ptr727 ptr727 commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Iteration branch for #25. Keep it open; never merge it. A clean single-commit branch for upstream is cut from it once it has baked. Pieter's decision on 2026-10-10: nothing goes upstream until a maintainer engages with one of our open PRs.

References:

  • The code:
  • The measurement: cli-reply-bound-harness.cpp, a host transcription of the writers and the wrapper, with inputs constructed in the program.

The defect

The repeater, room server and sensor wrappers echo an optional 3-byte xx| prefix into the reply and advance reply past it before calling CommonCLI::handleCommand(). A serial caller's char reply[160] and a remote caller's &temp[5] of uint8_t temp[166] therefore leave CommonCLI 157 and 158 bytes. Several of its writers bound themselves at 160 instead. #25 has the permalinks.

The fix

Evidence

Measured with the harness. Each command is at most 158 characters, which is what a serial command[160] keeps:

Command Bound Serial reply[160] Remote temp[166]
xx|set + a 151-character key 160 (dev) 2 bytes past the end 1 byte past the end
xx|set + a 151-character key 157 (this PR) 0 0
xx|region def + a 144-character name with a . 160 (dev) 3 bytes past the end 2 bytes past the end
xx|region def + a 144-character name with a . 157 (this PR) 0 0
xx|get owner.info, owner_info full (control) 160 or 157 0 0

Testing

  • Build: RAK_4631_repeater, RAK_4631_room_server, RAK_4631_sensor and heltec_v4_r8_repeater all build at 024254a4.
  • Host: the harness above.
  • Hardware: not run. The overrun is a stack write the device won't report, so a board would show nothing the harness doesn't. The only test board is held on the RV3028 acceptance build.

Notes

Refs #25

🤖 Generated with Claude Code

The repeater, room server and sensor wrappers echo an optional 3-byte
"xx|" prefix into the reply and advance `reply` past it before calling
CommonCLI::handleCommand(). Serial callers pass char reply[160] and
remote callers &temp[5] of uint8_t temp[166], so CommonCLI can rely on
157 bytes. Several of its writers bound themselves at 160 instead.

Two of them echo the admin's own text. "set" with an unknown 151-character
key writes 2 bytes past a serial reply and 1 past a remote one. "region
def" with a 144-character name that putRegion() rejects writes 3 and 2.
The region exports and "gps diag" share the same bound.

Add CLI_REPLY_SIZE (157) to CommonCLI.h and use it for every reply bound
in CommonCLI.cpp. A reply without the prefix loses at most its last 3
characters. ZephCore fixed the same overrun in liquidraver/ZephCore@ad23dcb,
by subtracting the prefix from its separate remote bound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings October 10, 2026 22:23
@coderabbitai

coderabbitai Bot commented Oct 10, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: bfe25dce-7040-4769-b5f8-f9899ee2ed54

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The changed bounds match the smallest caller capacity; the remaining documentation nit is non-blocking.

0 open findings

What changed in this PR

This PR limits CommonCLI replies to the 157 bytes available after a caller echoes an optional prefix, addressing the buffer overrun described in #25.

Changes:

  • Defines a shared reply-size limit.
  • Applies it to reply writers, including GPS diagnostics and region commands.
File Description
src/​helpers/​CommonCLI.h Defines and explains the 157-byte limit.
src/​helpers/​CommonCLI.cpp Uses the limit for affected reply bounds.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants