Skip to content

Fix SelfInfo frame length validation#256

Merged
Avi0n merged 2 commits into
Avi0n:devfrom
robekl:fix/selfinfo-frame-validation
Mar 17, 2026
Merged

Fix SelfInfo frame length validation#256
Avi0n merged 2 commits into
Avi0n:devfrom
robekl:fix/selfinfo-frame-validation

Conversation

@robekl

@robekl robekl commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • raise PacketSize.selfInfoMinimum from 55 to 57 bytes
  • add coverage for the minimum valid fixed-width SelfInfo payload and for truncated payload rejection

Why this is the correct fix

The current MeshCore firmware documentation describes PACKET_SELF_INFO as:

  • byte 0: packet type
  • bytes 1-57: fixed-width fields through radio spreading factor and coding rate
  • bytes 58+: optional device name

References:

PacketParser drops the response code before parsing, so the parser should require a minimum payload length of 57 bytes, not 55. With the old boundary, malformed frames missing radioSF/radioCR could still pass the initial size check and then be parsed incorrectly.

This change tightens validation to match the documented fixed-width frame while preserving valid firmware behavior, including payloads with no trailing device name.

Testing

Automated:

  • cd MeshCore && swift test
  • Result: 262 tests passed in 23 suites
  • Added tests cover:
    • valid 57-byte SelfInfo payload with no device name
    • invalid truncated 55-byte SelfInfo payload rejected with parse failure

Manual on device:

  • launched the app on an iPhone 16 Pro over USB from Xcode
  • paired and connected successfully to a MeshCore device
  • confirmed normal session startup, selfInfo reception, sync, and repeater interaction all still work

Relevant log proof from the successful on-device run:

Received event: selfInfo(MeshCore.SelfInfo(... name: "RKE2847"))
MeshCore session started
Received event: deviceInfo(MeshCore.DeviceCapabilities(firmwareVersion: 10, ... version: "v1.14.0-9f1a3ea" ...))
Full sync complete
Connection complete - device ready
[CMD] <- REPEATER CLI_RESP from=88fcce4bf302 resp="v1.14.0-9f1a3ea (Build: 06-Mar-2026)"

That gives both sides of the validation: the new parser still accepts real firmware frames on hardware, and the new tests prove truncated frames are rejected.

@Avi0n Avi0n left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thank you for this PR! Once the review changes are addressed, I'll merge this.

Comment thread MeshCore/Sources/MeshCore/Protocol/Parsers.swift Outdated
Comment thread MeshCore/Sources/MeshCore/Protocol/Parsers.swift Outdated
@robekl robekl requested a review from Avi0n March 17, 2026 20:09
@Avi0n

Avi0n commented Mar 17, 2026

Copy link
Copy Markdown
Owner

LGTM, thank you!

@Avi0n Avi0n merged commit 80ac2a3 into Avi0n:dev Mar 17, 2026
2 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.

2 participants