Repository navigation
Fix VHDX reads crossing a block boundary - #93
HaraldMuehlhoffCC wants to merge 2 commits into
Conversation
read_sectors() capped each iteration at a full block worth of sectors, regardless of where in the block the read started. A read starting in the middle of a block therefore continued past the end of the payload block in the file. That only returns the right data if the next virtual block happens to be stored directly after it. If the next block is not present, zero, unmapped or stored elsewhere in the file, the returned data is wrong (and conversely, a read starting in a zero block returned zeros for the following present block). Found on a wbadmin system image containing PAYLOAD_BLOCK_ZERO blocks: the content of files spanning such blocks depended on the read size. Cap each iteration at the sectors remaining in the current block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CDfghZiXWrcLJ41GPUMbLP
Document the arguments and return value of the BAT patching helper and describe the block boundary test, following the style guide. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CDfghZiXWrcLJ41GPUMbLP
|
@HaraldMuehlhoffCC thank you for your contribution! As this is your first code contribution, please read the following Contributor License Agreement (CLA). If you agree with the CLA, please reply with the following information:
Contributor License Agreement
Contribution License AgreementThis Contribution License Agreement ("Agreement") governs your Contribution(s) (as defined below) and conveys certain license rights to Fox-IT B.V. ("Fox-IT") for your Contribution(s) to Fox-IT"s open source Dissect project. This Agreement covers any and all Contributions that you ("You" or "Your"), now or in the future, Submit (as defined below) to this project. This Agreement is between Fox-IT B.V. and You and takes effect when you click an “I Accept” button, check box presented with these terms, otherwise accept these terms or, if earlier, when You Submit a Contribution.
|
|
@DissectBot agree |
read_sectors()capped each iteration at a full block worth of sectors, regardless of where in the block the read started, so reads straddling a block boundary continued past the end of the payload block in the file. Each iteration is now limited to the sectors remaining in the current block.Adds parametrized regression tests based on
fixed.vhdx.gzwith a distinct fill pattern per payload block and a modified BAT (present→zero, zero→present, not present, non-contiguous payload blocks), read in one go, straddling a single boundary and spanning several blocks. Without the fix, 8 of the new cases fail.How to test
Results on Linux with the Git LFS test data:
lintOK (ruff check, ruff format --check, vermin),py310andpy31172 passed each; the VHDX tests alone: 30 passed.Fixes #92