fix(pe): detect incomplete TLS callback arrays #324
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/324"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by pedrofort on 2026-11-24T02:18:01Z.
<head></head>
Problem
parse_tls()silently accepts callback arrays that reach the end of the available section data without a null terminator, or contain more thanMAX_TLS_CALLBACKSentries.In both cases,
ImageInfo::parse()can return a partial callback list without reporting an error.Proposed fix
Report an explicit malformed-image error for unterminated callback arrays.
Reject arrays exceeding the existing 1,024-callback limit instead of silently truncating them.
Preserve valid empty arrays, null callback pointers and arrays containing exactly 1,024 callbacks followed by a terminator.
One compatibility detail for review: whether callback arrays terminated by implicit zero-filled virtual memory should also be accepted.
Verification
Tested on Apple M5, macOS arm64, Rust 1.98.1, against main
Check | Before | After -- | -- | -- Synthetic TLS tests | 4 passed, 2 failed | 6 passed, 0 failed Portable PE unit tests | — | 9 passed, 0 failed Clippy | — | Clean Asset policy | — | 151 files OKd2a4bae.The four existing Windows-specific own-binary tests were excluded from the portable PE test run.
All new fixtures are generated in memory. No game data was used.
AI-assisted implementation and test preparation (ChatGPT). Commands executed and results verified locally.
Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T04:20:19Z.
Tested PR #324 at head
8fc3a1bb2f37c6220c8f9a397ff5d1a99f6e34a7(state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged at8fc3a1bb2f37c6220c8f9a397ff5d1a99f6e34a7.cargo test --locked -p victory-pe --lib tls_probe_— passed (ok. 6 passed; 0 failed; 0 ignored; 0 measured; 7 filtered out; finished in 0.00s ); cases: image::tests::tls_probe_accepts_terminated_callbacks, image::tests::tls_probe_accepts_null_callback_pointer, image::tests::tls_probe_accepts_empty_callback_list, image::tests::tls_probe_accepts_exact_callback_limit, and 2 more.Behavior covered: Checks TLS callback arrays accept terminated, empty and null forms while rejecting unterminated and over-limit arrays.
Code: crates/victory-pe/src/image.rs
Imported from Marvisak/VIctory. Originally posted by etcetera-yt on 2026-11-24T05:36:31Z.
The synthetic-image tests expect
ImageInfo::parseto succeed on an image whose TLS callback array is past thecap or runs to the end of its section (capping or stopping there). #324 rejects both images as malformed. The two
PRs disagree on the intended behaviour; one of them needs to change, and the maintainer should pick which.
Merged with plain
git merge, no text conflict. Windows 10 19045, Rust 1.98.1,cargo test -p victory-pe tls_callback.AI use: Claude Code, Claude Opus 5.5.
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T13:03:18Z.
Review: APPROVED
Tested
8fc3a1bon Windows 11, RTX 5070, MSVC:cargo test -p victory-pe13 passed, including the terminated, unterminated and over-limit TLS tests.cargo clippy -p victory-pe --all-targetsis clean.victory inspecton a local title executable parses as before (same output and no error), so the stricter check doesn't reject a real image.MAX_TLS_CALLBACKS(1024), instead of silently truncating, avoids running a partial set.cargo fmt -p victory-pe --checkreports diffs in the new tests (the hand-wrappedcopy_from_slice(andImageInfo::parse(calls). Runningcargo fmton the file would tidy them.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by pedrofort on 2026-11-24T20:14:29Z.
Follow-up at
c37793a059: fixed a reproduced synthetic compatibility defect involving TLS terminators in zero-filled virtual memory. All 9 focused TLS tests and portable PE regressions passed on Apple M5. Formatting and asset policy passed. Platform-specific own-PE tests were excluded on macOS; the IAT test failure was independently reproduced on the original commit. Whether this fixes the reported title-loading regression remains unverified. Independent retesting appreciated. AI-assisted with ChatGPT.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:31:34Z.
Automated triage for the maintainers.
Proposed close: adds load failures for cases that do not occur. This makes
parse_tls(crates/victory-pe/src/image.rs) reject an image whose TLS callback array is unterminated within the section's raw data, or has more than 1,024 callbacks (main already caps the walk atMAX_TLS_CALLBACKS). The Windows loader rejects neither case, so this is stricter than Windows: such an image would now fail to load. No real image is shown to have the problem, the title loads with today's behaviour, and a reviewer reports it conflicts with the expectations of the other open TLS PRs (#287, #311). A version that logs a warning instead of failing the parse would be a different proposal.CI:
checkpassing.This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the
triage: proposed closelabel.Generated by Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.