fix(pe): detect incomplete TLS callback arrays #324
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!324
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@pedrofort on GitHub · 2026-11-24 02:18 UTC · original
<head></head>pedrofort:fix-tls-callback-termination→main· +169 −1 · 1 files · 2 commits · openProblem
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.
@jeremygold02 on GitHub · 2026-11-24 04:20 UTC · original
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
@etcetera-yt on GitHub · 2026-11-24 05:36 UTC · original
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.
@pedrofort on GitHub · 2026-11-24 20:14 UTC · original
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.@Marvisak on GitHub · 2026-11-25 00:31 UTC · original
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.