metadata: add fixes for metadata handling #111
Merged
Conversation
Fix critical bug in cio_file_write_metadata() where memmove() was using metadata size instead of content data size when moving content after metadata expansion. This caused data corruption when metadata size differed from content size. Also fix available space calculation to properly account for header and metadata when determining if file resize is needed. Fixes issue where updating metadata after writing content data would corrupt the content when metadata grew larger. Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Add comprehensive tests to validate that updating metadata after writing content data correctly preserves both metadata and content integrity. The tests specifically cover the scenario where metadata grows and requires content data to be moved. Tests include: - Single metadata update with content data - Multiple metadata updates with varying sizes - Validation after chunk down/up cycles Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The resize check in cio_file_write_metadata calculated: content_av = alloc_size - CIO_FILE_HEADER_MIN - size When writing large metadata to a chunk with small initial allocation, this subtraction could underflow (wrap to huge unsigned value), causing the resize check to be skipped and leading to out-of-bounds writes. Fixed by checking if resize is needed before any subtraction: if (alloc_size < CIO_FILE_HEADER_MIN + size + data_size) Also added a regression test in tests/fs.c to verify the fix. Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
No description provided.