Skip to content

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