Fix C API pointer provenance under Miri#191
Merged
oyvindln merged 5 commits intoFrommi:masterfrom Apr 22, 2026
Merged
Conversation
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
Miri rejected several C API entry points in
miniz_oxide_c_apias UB.The bug pattern was the same in each case: take a raw pointer, turn it into a
&u8or&mut u8, and then widen that one-byte reference into a larger slice withslice::from_raw_partsorslice::from_raw_parts_mut.That is not a sound way to construct the slice. This PR constructs the slices directly from the original raw pointers instead.
Changes
#[test]witnesses for the failing Miri pathstdefl_compresstdefcallback bridge to passout.as_ptr()instead of&(out[0])StreamOxide::try_newmz_adler32mz_crc32tdefTesting
Ran:
Both pass.
Attribution
OpenAI Codex implemented the witnesses and fixes.
@lopopolo reviewed and validated the work.