fix: validate file_size_bytes and footer_size from metadata#66
Merged
fix: validate file_size_bytes and footer_size from metadata#66
Conversation
Replace unsafe `as u64` cast for file_size_bytes with `u64::try_from()` + clear error. Skip negative footer_size values instead of wrapping to huge usize. Negative values in catalog metadata indicate corruption; now caught early with clear errors. Closes #58, closes #59 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
resolve_path() returns String, not Result, so .map_err() calls on it were compile errors. Also apply rustfmt formatting fixes.
Apply validated_file_size() to all unchecked `size_bytes as u64` casts in build_delete_file_scan() and build_data_file_scan(). Use usize::try_from() for footer_size casts for 32-bit platform safety. This prevents negative i64 values from wrapping to huge u64 values.
…cation Replace bare `footer_size as usize` casts with `usize::try_from(footer_size)` to prevent silent truncation on 32-bit platforms where a positive i64 value exceeding u32::MAX would wrap. Apply consistently across table.rs and table_changes.rs to match the pattern already used in table_deletions.rs.
9394a57 to
02f04f6
Compare
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.
Summary
as u64cast forfile_size_byteswithu64::try_from()+ clear errorfooter_sizevalues instead of wrapping to huge usizeTest plan
cargo testpasses🤖 Generated with Claude Code