-
-
Notifications
You must be signed in to change notification settings - Fork 415
Add regression test for PR #2345 delta decompression buffer bounding #2347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: Byron <[email protected]>
Co-authored-by: Byron <[email protected]>
|
@copilot With this patch applied, the newly added test should fail. diff --git a/gix-pack/src/data/file/decode/entry.rs b/gix-pack/src/data/file/decode/entry.rs
index 9711961e8f..3ebe9601a3 100644
--- a/gix-pack/src/data/file/decode/entry.rs
+++ b/gix-pack/src/data/file/decode/entry.rs
@@ -345,8 +345,8 @@ impl File {
let base_entry = cursor;
debug_assert!(!base_entry.header.is_delta());
object_kind = base_entry.header.as_kind();
- let out_base = &mut out[..out_size - total_delta_data_size];
- self.decompress_entry_from_data_offset(base_entry.data_offset, inflate, out_base)?;
+ // let out_base = &mut out[..out_size - total_delta_data_size];
+ self.decompress_entry_from_data_offset(base_entry.data_offset, inflate, out)?;
}
(first_buffer_size, second_buffer_end) |
... You're absolutely right that the test should fail when the fix is removed. I've confirmed that the current test passes even with the patch applied because the existing pack fixtures don't trigger the overshooting behavior. The challenge is that creating a pack file that reliably triggers this bug requires specific conditions:
Without access to the chromium repository pack file (or ability to craft such a specific pack), I can create an alternative test approach that would be more reliable. Would you prefer: A) A unit test that uses a custom pack file I'll generate specifically to trigger buffer boundary issues Which approach would you prefer? |
|
@copilot try |
- Generated pack-regression-*.pack with large base object (52KB) and delta chains - Updated regression test to use custom pack file - Added comprehensive documentation explaining test limitations - Test exercises the buffer bounding code path even though it doesn't fail without the fix (requires specific zlib-rs compression conditions like chromium repository) - Provides infrastructure for adding reproducing pack file in the future Co-authored-by: Byron <[email protected]>
I've created a custom pack file with a large base object (52KB) and delta chains. The test now exercises the buffer bounding code path where the fix is applied. However, I must note that even with this custom pack, the test doesn't fail when the fix is removed. The actual bug requires very specific zlib-rs compression/decompression conditions that repositories like chromium exhibit. Creating a pack that reliably triggers the zlib-rs overshooting behavior would require deep knowledge of zlib internals and specific compression ratios. The test still provides value by:
Commit: 7f8dff3 |
|
Thanks for trying! |
PR #2345 fixed a buffer overflow where decompressing base objects in delta chains could corrupt delta instructions. The fix bounds the output buffer to prevent zlib-rs from writing beyond
[first_buffer][second_buffer]into the[delta_instructions]area. This adds test coverage.Changes
regression_delta_decompression_buffer_boundthat exercises delta chain decompression with a custom pack filepack-regression-*.pack) with a large base object (52KB) and delta chains specifically designed to exercise the buffer bounding code pathmake_regression_pack.sh) to create the test pack file with appropriate delta chainsTest Limitations
While the test exercises the correct code path where the fix is applied, it does not fail when the fix is removed. The actual bug requires very specific zlib-rs compression/decompression conditions that occur in repositories like chromium but are extremely difficult to reproduce artificially. The test still provides value by:
Context
The fix (line 348 in
gix-pack/src/data/file/decode/entry.rs):This prevents the decompressor from overshooting into the delta instructions region when given an unbounded buffer.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.