Skip to content

fix: protocol parser edges (review P1-4) - #203

Open
Derrors wants to merge 3 commits into
mainfrom
fix/p1-parsers
Open

Derrors wants to merge 3 commits into
mainfrom
fix/p1-parsers

Conversation

@Derrors

@Derrors Derrors commented Nov 25, 2026

Copy link
Copy Markdown
Owner

What and why

P1, fourth batch, from the full review of main after #195: protocol parser edges.

  • ictl-ax
    • xml.rs: with no known word, a text field was taken for the lock screen's passcode field when the larger of its two numbers was 4 or 6. So "6:00", "2/4" and "1.6" became a SecureTextField, and cover_sheet then read the screen as locked. The fallback now also needs words between the numbers (digit_runs); every language's field reads as a sentence, while times, fractions and decimals have punctuation only. "6 中 3" still counts.
    • tree::assemble looked attributes up by the whole ObjectRef, is_app included: a child referenced with the other flag was left out with its subtree. Now it looks up by (pid, id) and keeps the stored reference.
    • dtx.rs: fragment + 1 was a u16 sum (it overflowed on fragment 65535); fragments carrying nothing could come without end; conversation + 1 could overflow. Now: compared in u32, at most 4096 fragment headers per message, wrapping_add.
  • ictl-webinspector
    • evaluate closes and forgets the session on every path. A failed setup used to leave open_sessions and data behind, and the session's messages kept piling up.
    • A write that stops half-way sets broken: nothing more is written, and is_broken() tells the daemon, which drops the connection even when the value came back. The close's timeout used to be swallowed by let _ =, and the out-of-step connection was reused.
    • WIRFinalMessageKey counts toward the 64 MB limit.
    • A refused Target.sendMessageToTarget wrapper ends the wait (answer_to) instead of running to the timeout.
  • ictl-wda http.rs
    • dechunk: size + 2 is checked and each chunk must end in CRLF.
    • Trailers are read through. A body ending in trailers never looked complete (ends_with("0\r\n\r\n")), and WDA doesn't close the connection, so it waited for the timeout.
    • A head that doesn't end within 64 KB is refused, instead of scanning those 64 KB again after every read up to 64 MB.
  • FLV: a header length outside 9–1024 is refused (it was waited for, up to 4 GB).
  • vt.rs (macOS)
    • CFDataGetLength goes through usize::try_from.
    • build_avcc refuses what its fields can't hold (over 31 SPS, over 255 PPS, sets over 64 KB).
    • The encoding thread waits while 8 H.264 frames it sent are untaken (Sink::queued, counted as sent, so frames the encoder drops never block it); meanwhile push keeps replacing the waiting JPEG.

Tests

1. Unit tests

  • cargo test --workspace --all-features --locked: 587 passed; clippy -D warnings; cargo fmt --check for all 11 packages; tests/check_regression_cases.py: 0 missing
  • New: a_child_is_found_whatever_its_reference_says_about_being_an_app, odd_fragment_counts_end_and_counters_dont_overflow, a_failed_write_leaves_nothing_behind, a_refused_wrapper_ends_the_wait, a_huge_last_piece_is_refused, chunked_edges, an_endless_head_is_refused; cases added to the_lock_screen_passcode_field_reads_as_secure, other_input_is_an_error (FLV), avcc_from_parameter_sets (macOS)
  • No test removed, ignored or loosened
  • vt.rs only builds on macOS: compiled and tested by the CI's macOS job, not here

2. Real-device regression

  • iPhone 15 Pro Max (iPhone16,2) iOS 27.2.1, native; iPad mini 5 (iPad11,1) iPadOS 26.7.3, WDA; Debian 12
  • tests/device/run.py:
    • iPhone: 5 runs. The first, right after the deploy, had 1 failed step that didn't show which, with nothing in the daemon's log; the 4 after it had 0 failed.
    • iPad (WDA, the new HTTP reader): 16 calls, 0 failed.
  • Background-poll stress on the iPhone: 24 actions, 0 failed

3. Regression cases

  • Added #224–#230

4. Real-device proof

  • Locked, then a link opened: unlocked itself (the passcode field and lock screen still recognised)
  • web_eval on Safari's example.com: document.title + location.host and a promise (42) both answered
  • /video through the viewer (H.264 through the FLV reader): 1.7 MB in 6 s
  • Not tried: malformed answers from a real phone (unit-tested); a page slow to take the macOS encoder's frames; macOS

Checklist

  • MCP tool names, parameters and default outputs stay compatible (D10)
  • No new dependencies
  • CHANGELOG.md and CHANGELOG.zh-CN.md (Unreleased)
  • No private data in the outputs above

🤖 Generated with Claude Code

Derrors and others added 3 commits November 25, 2026 23:20
- ax: the passcode field fallback needs words between the numbers ("6:00" isn't
  one); assemble looks attributes up by (pid, id); DTX fragments are counted
  and compared in u32, conversations wrap
- webinspector: a session is closed and forgotten on every path; a write that
  stops half-way marks the connection broken (the daemon reopens it); the
  final piece counts toward the size limit; a refused Target wrapper ends the
  wait
- WDA HTTP: chunk sizes can't overflow and must end in CRLF; trailers are read
  through; a head that doesn't end in 64 KB is refused
- FLV: a header length past 1 KB is refused
- vt.rs (macOS): CFData lengths checked, avcC field limits, at most 8 H.264
  frames ahead of the caller

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…in 1.99, try_update not in 1.89)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A head not ended within 64 KB is refused once 64 KB are read: parse_head
  looks no further, so more bytes can't complete it.
- The doc line of `response_for` had ended up above `answer_to`'s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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