Repository navigation
Reject truncated LiME payloads during block conversion - #883
Closed
Jaeyou PARK (cpuu) wants to merge 1 commit into
Closed
Jaeyou PARK (cpuu) wants to merge 1 commit into
Jaeyou PARK (cpuu) wants to merge 1 commit into
Conversation
Author
|
@microsoft-github-policy-service agree |
Collaborator
|
Thanks Jaeyou PARK (@cpuu) for finding and fixing the truncated LiME payload issue. While reviewing the other conversion paths, we found the same unchecked-short-read behavior in LiME-to-raw and compressed conversions. Compressed records could also be accepted without their existing length trailer because seeking past EOF succeeds. We opened #884 to apply the fix consistently across all conversion paths and validate the compressed-length trailer. Your PR provided the original diagnosis and regression case; #884 broadens that work rather than replacing the underlying fix. |
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.
A truncated LiME record can currently be converted successfully even when its payload is shorter than the range declared in its header.
For example, a record declaring 4096 bytes but containing only 4095 bytes is accepted. The unaligned copy path ignores the byte count returned by
std::io::copy, leaving the missing byte as zero in the preallocated buffer. The output therefore contains a zero byte that was not present in the input. An entirely missing payload can also be silently treated as an all-zero block and omitted.This change checks the copied byte count and returns
UnexpectedEofbefore emitting the incomplete block. It also makes short-read handling consistent with the existing page-aligned path, which usesread_exact.One parameterized regression test covers empty, one-byte-short, and complete payloads for both LiME and compressed AVML output.
Validation
--no-default-features --features convert.The change is limited to the shared unaligned block-copy path.
If accepting truncated payloads is intentional, please let me know. I could not find a documented recovery policy for this behavior, so this PR proposes reporting the incomplete input rather than silently padding it.