Skip to content

gate GET_ADVERTISING_NAME on cmd_status - #58

Merged
abdulsaheel merged 1 commit into
mainfrom
fix/advname-status-gate
Sep 18, 2026
Merged

abdulsaheel merged 1 commit into
mainfrom
fix/advname-status-gate

Conversation

@abdulsaheel

@abdulsaheel abdulsaheel commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

same bug as the battery/hello/clock reads, just on the adv-name opcode. getAdvertisingNameHarvard/getCustomAdvertisingName decoded the reply body unconditionally, no status check. on a failure/pending/unsupported reply the body is stale, and _decodeAdvName's printable-run fallback can turn stale bytes into a plausible name that gets surfaced as strap_name in pairing/settings.

fix is the same one-line gate the sibling opcodes already have (if status == 1). added a regression test covering status 0/2/3 on both gen4 and gen5.

Summary by Sourcery

Gate advertising-name decoding on successful command status to avoid reporting stale strap names.

Bug Fixes:

  • Prevent stale response data from being surfaced as the advertising name when GET_ADVERTISING_NAME returns a failure, pending, or unsupported status.

Tests:

  • Add regression coverage for non-success advertising-name responses on both Gen4 and Gen5 profiles.

was decoding the strap-name reply unconditionally, so a failure/pending
reply's stale body bytes could get decoded into a plausible-looking name
and surfaced as strap_name. same pattern as the battery/hello/clock gates.

@sourcery-ai sourcery-ai Bot 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.

Sorry @abdulsaheel, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 6 days and 17 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 9 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 39b35bc1-8607-4466-9a93-31f07e040271

📥 Commits

Reviewing files that changed from the base of the PR and between 3a96e1d and dc7d35c.

📒 Files selected for processing (2)
  • lib/src/control.dart
  • test/control_plane_offsets_test.dart

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.

@sourcery-ai

sourcery-ai Bot commented Sep 18, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR fixes stale-data leakage for GET_ADVERTISING_NAME by status-gating advertising-name decoding on successful responses, with regression tests covering failure, pending, and unsupported statuses across gen4 and gen5.

Sequence diagram for status-gated advertising name decoding

sequenceDiagram
    participant Device
    participant Parser as parseCommandResponse
    participant Decoder as _decodeAdvName
    participant Consumer as PairingOrSettings

    Device->>Parser: GET_ADVERTISING_NAME response
    alt status == 1
        Parser->>Decoder: _decodeAdvName(payload)
        Decoder-->>Parser: strap_name
        Parser-->>Consumer: decoded advertising name
    else status != 1
        Parser-->>Consumer: no strap_name
    end
Loading

Flow diagram for preventing stale advertising names

flowchart TD
    A[GET_ADVERTISING_NAME response] --> B{status == 1?}
    B -->|Yes| C["_decodeAdvName(payload)"]
    C --> D[Expose strap_name]
    B -->|No: failure, pending, or unsupported| E[Skip body decoding]
    E --> F[Prevent stale bytes becoming strap_name]
Loading

File-Level Changes

Change Details Files
Only decode advertising names from successful command responses.
  • Gate strap_name decoding on status == 1 for both gen4 and gen5 advertising-name opcodes.
  • Preserve the existing payload decoder while preventing stale failure, pending, or unsupported reply bytes from being surfaced.
lib/src/control.dart
Add regression coverage for non-success advertising-name responses.
  • Test statuses 0, 2, and 3 on both gen4 and gen5.
  • Use printable stale bytes that could otherwise produce a plausible advertising name, and verify strap_name is absent.
test/control_plane_offsets_test.dart

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@abdulsaheel
abdulsaheel merged commit 5f6ed0d into main Sep 18, 2026
4 checks passed
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.

1 participant