Skip to content
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

Ensured that original buffer is initialized in test_decompression #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

icmccorm
Copy link

We've been prototyping a version of Miri that can execute foreign functions. It found a bug in the test case test_decompression.

THe buffer orig is only partially initialized

let mut orig: Vec<u8> = Vec::with_capacity(*sz);
unsafe {
    orig.set_len(*sz);
    {
        //it's sort of randomized data
        orig[0] = 1;
        orig[*sz / 4] = 4;
        orig[*sz / 2] = 7;
        orig[*sz * 2 / 3] = 10;
        orig[*sz - 1] = 1;
    }

Later, its contents is compared against another buffer using assert_eq!

assert_eq!(&orig[0..*sz], &buf[0..cz]);

This uses the intrinsic compare_bytes, which requires both slices to be fully initialized.

Commit b45549d fixes this by zero-initializing the buffer orig using orig.fill(0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant