Skip to content

Fix memory unsafety in Reader::push by simply removing it #21902

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

Closed
wants to merge 1 commit into from

Conversation

tbu-
Copy link
Contributor

@tbu- tbu- commented Feb 3, 2015

The memory unsafety was caused by the fact that it passed an uninitialized
buffer to a different function (Reader::read) which might not give the
(unsafe) guarantee that it doesn't touch the uninitalized bytes.

If one removes this unsafety, the function is no better than creating an
initialized vector and passing it to the Reader::read function, so it was
removed completely.

Fixes #21896.

The memory unsafety was caused by the fact that it passed an uninitialized
buffer to a different function (`Reader::read`) which might not give the
(unsafe) guarantee that it doesn't touch the uninitalized bytes.

If one removes this unsafety, the function is no better than creating an
initialized vector and passing it to the `Reader::read` function, so it was
removed completely.

Fixes rust-lang#21896.
@rust-highfive
Copy link
Contributor

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@tbu-
Copy link
Contributor Author

tbu- commented Feb 3, 2015

See also #21076.

@tbu-
Copy link
Contributor Author

tbu- commented Feb 3, 2015

r? @alexcrichton

@alexcrichton
Copy link
Member

For now I think we'd prefer to avoid breaking changes to old_io wherever possible. This will naturally get phased out over time and the new std::io implementation is hopefully [soon to land]#21835) (which does not have this problem).

If you'd like to submit a fix for this though (using the black_box trick), then feel free to reopen!

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.

Reader::push function does not abstract its unsafe interior away properly
4 participants