Skip to content

fix(usb): accept the padding iOS 27 adds after USBMUX replies - #43

Open
code-new-bie wants to merge 1 commit into
shilapi:masterfrom
code-new-bie:pr/usbmux-ios27-padding
Open

code-new-bie wants to merge 1 commit into
shilapi:masterfrom
code-new-bie:pr/usbmux-ios27-padding

Conversation

@code-new-bie

Copy link
Copy Markdown

An iPhone on iOS 27 can send four extra bytes after some USBMUX replies: the
version reply declares 20 bytes and arrives as 24, and TCP replies, with or
without data, can carry the same trailer. Iap2UsbMuxHost read those bytes as
the start of the next header, got a length of 6 and ended the wired session
with "Invalid USBMUX frame length 6".

Framing now goes through UsbMuxFrameBuffer. Exactly four bytes are skipped,
only after the version reply, a valid TCP reply from the iPhone or a
diagnostic reply, and only when a valid header follows; incomplete data waits
for more instead of being dropped, and any other bad length still fails.
Skips and rejections are reported through a new onDiagnostic hook, which
CarPlayController writes to its debug log.

The fix and its tests come from DiPlay (shihabal3amri/DiPlay, commits
3d0411d5 and f7af3286, for its issue #100), which shares this code with
xcertplay; both are GPL-3.0. UsbMuxIssue100RegressionTest replays the USB
transfers captured in that issue through the real Iap2UsbSession read and the
Iap2UsbMuxHost handshake, so shared gains a Robolectric test dependency.

An iPhone on iOS 27 can send four extra bytes after some USBMUX replies: the
version reply declares 20 bytes and arrives as 24, and TCP replies, with or
without data, can carry the same trailer. Iap2UsbMuxHost read those bytes as
the start of the next header, got a length of 6 and ended the wired session
with "Invalid USBMUX frame length 6".

Framing now goes through UsbMuxFrameBuffer. Exactly four bytes are skipped,
only after the version reply, a valid TCP reply from the iPhone or a
diagnostic reply, and only when a valid header follows; incomplete data waits
for more instead of being dropped, and any other bad length still fails.
Skips and rejections are reported through a new onDiagnostic hook, which
CarPlayController writes to its debug log.

The fix and its tests come from DiPlay (shihabal3amri/DiPlay, commits
3d0411d5 and f7af3286, for its issue #100), which shares this code with
xcertplay; both are GPL-3.0. UsbMuxIssue100RegressionTest replays the USB
transfers captured in that issue through the real Iap2UsbSession read and the
Iap2UsbMuxHost handshake, so shared gains a Robolectric test dependency.
code-new-bie added a commit to code-new-bie/xcertplay that referenced this pull request Oct 12, 2026
Eight pull requests (shilapi#43 to shilapi#50) and one issue (shilapi#51) went to shilapi/xcertplay, each built on upstream 1.4.0 with one change. docs/UPSTREAM.md lists them with the commits of this branch they come from, and what was left out and why.
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