test(pe): cover header layout offsets #311
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/311"
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 CesarLopesO on 2026-11-24T02:14:20Z.
Summary
e_lfanewpointer.Validation
Passed:
cargo test -p victory-pe --lib layout::tests— 4 passed.rustfmt --edition 2024 --check crates/victory-pe/src/layout.rscargo clippy -p victory-pe --all-targets -- -D warningscargo xtask policy— 151 files.git diff --checkEnvironment note:
cargo test --locked -p victory-pereports 4 failures in existingimage::testson Debian/Linux. These tests parse the current test executable as a PE32+ binary, but Linux produces an ELF executable. The failures are in unchangedcrates/victory-pe/src/image.rs; all new layout tests pass.Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T04:18:59Z.
Tested PR #311 at head
95f5390a5cebc8ed9ab2349960dd7e93e26b6064(state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged at95f5390a5cebc8ed9ab2349960dd7e93e26b6064.cargo test --locked -p victory-pe --lib layout::tests— passed (ok. 4 passed; 0 failed; 0 ignored; 0 measured; 6 filtered out; finished in 0.00s ); cases: layout::tests::reads_reject_overflowing_offsets, layout::tests::data_directory_offsets_respect_declared_entry_count, layout::tests::header_offsets_follow_the_dos_header_pointer, layout::tests::header_offset_helpers_reject_truncated_headers.Behavior covered: Checks PE layout offset helpers use the DOS header pointer, respect declared directory counts, and reject truncated/overflowing headers.
Code: crates/victory-pe/src/layout.rs
Imported from Marvisak/VIctory. Originally posted by TrashTalker3460 on 2026-11-24T05:51:09Z.
Note on head
95f5390: this test and #396 can't both land as written.data_directory_offsets_respect_declared_entry_count(crates/victory-pe/src/layout.rs:114) builds a header whoseSizeOfOptionalHeaderis 0 and expectsdata_directory_offset(&data, 0) == Some(first). #396 bounds the lookup toSizeOfOptionalHeader(itslayout.rs:83–97), so the same input returnsNone. If #396 goes in, settingSizeOfOptionalHeaderin the fixture would keep the test meaningful.Read-only review, nothing built. AI-assisted (Claude Code); the claim above was checked against this head and
mainatd2a4bae. Context: the triage in #366.Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T08:36:05Z.
Review: APPROVED
Tested
95f5390on Windows 11, RTX 5070, MSVC:cargo test --workspace --no-fail-fastpasses (267 passed, 0 failed).These are test-only additions. They cover
e_lfanew-relative offsets, theNumberOfRvaAndSizesbound on data directories, and rejection of truncated DOS and optional headers, all on synthetic buffers. The expected offsets (0x44, 0x58, and data directory + 8) match the PE32+ layout.No issues found.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T13:09:59Z.
Review: APPROVED
Re-tested
1251a24on Windows 11, RTX 5070, MSVC:cargo test -p victory-pepasses, 20 tests on mercuryVM/VIctory main with this head merged (the earlier head is already there).file_header_offset0x44 andoptional_header_offset0x58 fore_lfanew0x40), the declared directory count, and truncated headers. They pass both with and without theSizeOfOptionalHeadercheck from #396, so they don't depend on which of the two lands first.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:01:19Z.
Automated triage for the maintainers. Closing because another open pull request covers the same change.
See #1171. Three small tests for layout.rs offset helpers; correct (one 'truncated header' assert passes only because the count field reads 0). Fully covered by #1171's layout tests, and the two collide in the same test module.
If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed