Skip to content

fix(usbmux): handle decoder errors and preserve unconsumed bytes on connect - #304

Merged
harsha509 merged 4 commits into
mainfrom
fix/usbmux-decoder-byte-loss
Aug 27, 2026
Merged

fix(usbmux): handle decoder errors and preserve unconsumed bytes on connect#304
harsha509 merged 4 commits into
mainfrom
fix/usbmux-decoder-byte-loss

Conversation

@harsha509

@harsha509 harsha509 commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Fixes three issues in the usbmux layer.

  • Malformed frames crashed the process because parsePlist errors were not caught. The decoder now emits an error event instead.
  • The LengthBasedSplitter was piped from the socket but never consumed, so it buffered all traffic. It is removed since the decoder does its own framing.
  • connect() dropped bytes that arrived after the Result frame in the same chunk. They are now pushed back to the socket so the caller receives them.

Adds unit tests for all three cases.

@mykola-mokhnach

Copy link
Copy Markdown
Collaborator

do we ever risk buffer overflow? I don't see any limits imposed other to its size

@harsha509

Copy link
Copy Markdown
Collaborator Author

do we ever risk buffer overflow? I don't see any limits imposed other to its size

HI @mykola-mokhnach ,

it was pre existing, the old cap never protected this path.

do we ever risk buffer overflow? I don't see any limits imposed other to its size

Hi @mykola-mokhnach,
this was pre-existing rather than introduced here.

The old MAX_FRAME_SIZE cap never protected the decode path because the splitter output was never consumed, the decoder has always been piped raw from the socket.

This PR keeps that behavior unchanged and only fixes the crash, the dead splitter, and the byte loss on connect.

@harsha509
harsha509 merged commit 52db21c into main Aug 27, 2026
9 checks passed
@harsha509
harsha509 deleted the fix/usbmux-decoder-byte-loss branch August 27, 2026 07:04
github-actions Bot pushed a commit that referenced this pull request Aug 27, 2026
## [5.16.1](v5.16.0...v5.16.1) (2026-08-27)

### Bug Fixes

* **usbmux:** handle decoder errors and preserve unconsumed bytes on connect ([#304](#304)) ([52db21c](52db21c))
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 5.16.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants