Repository navigation
PE: checked offsets in rva_to_file_offset and layout, remove dbg_tls - #30
Merged
Merged
Conversation
A section whose PointerToRawData lies near 4 GiB made file_offset + delta overflow: a panic in debug builds, a wrong offset in release ones. The section now yields no offset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Removes the print-only dbg_tls test in image.rs (TLS presence is already asserted in parses_own_test_binary) and switches layout.rs offset helpers (read_u32, read_u64, optional_header_offset, file_header_offset, data_directory_offset) to checked arithmetic so extreme offsets return None instead of overflowing.
|
Could not run the Linux check for this head: it conflicts with #39 (the PR that makes the workspace build and test on Linux), so it cannot be stacked without a rebase.
A rebase of this branch onto #39 (or a version of it after #39 lands) would let me run AI-assisted (DeepSeek V4.1 Flash coding agent). |
Contributor
|
Verified
AI-assisted. |
suirentakamura
referenced
this pull request
in suirentakamura/victory-suiren
Nov 24, 2026
PE: checked offsets in rva_to_file_offset and layout, remove dbg_tls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two small checked-arithmetic fixes and a test cleanup in
victory-pe:ImageInfo::rva_to_file_offset(image.rs): switchess.file_offset + deltatochecked_addso a section header withPointerToRawDatanear 4 GiB returnsNoneinstead of overflowingu32(panic in debug builds, wrapped offset in release). Adds regression testrva_to_file_offset_rejects_offsets_past_4_gib.layout.rs): switchesread_u32,read_u64,optional_header_offset,file_header_offsetanddata_directory_offsetto checked arithmetic so extreme offsets returnNoneinstead of overflowing. Adds regression testreads_reject_overflowing_offsets.image.rs): removes the leftover print-onlydbg_tls::dump_tlstest (TLS presence is already asserted inparses_own_test_binary).Testing
cargo test -p victory-pe: 6 passed, 0 failed.cargo clippy -p victory-pe --all-targets: 0 warnings.cargo xtask policy: pass (148 files).