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

from_elem is unsound when clone can panic #101

Closed
mbrubeck opened this issue Jun 14, 2018 · 2 comments
Closed

from_elem is unsound when clone can panic #101

mbrubeck opened this issue Jun 14, 2018 · 2 comments
Assignees
Labels

Comments

@mbrubeck
Copy link
Collaborator

If clone panics during SmallVec::from_elem then uninitialized memory is dropped. [Original report by dbaupp on Reddit.]

This bug was introduced by #93 which is not yet included in the latest published release (0.6.2).

The suggested solution is to use something like SetLenOnDrop to make sure the length is set correctly when destructors run, without inhibiting optimizations.

@mbrubeck mbrubeck added the bug label Jun 14, 2018
mbrubeck added a commit to mbrubeck/rust-smallvec that referenced this issue Jul 18, 2018
@mbrubeck mbrubeck self-assigned this Jul 18, 2018
mbrubeck added a commit to mbrubeck/rust-smallvec that referenced this issue Jul 18, 2018
bors-servo pushed a commit that referenced this issue Jul 19, 2018
Panic-safety fixes

* Make from_elem panic-safe.  Fixes #101.
* Make insert_many panic-safe.  Fixes #96.

r? @SimonSapin or @jdm.  cc @Vurich

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-smallvec/103)
<!-- Reviewable:end -->
@Phosphorus15
Copy link

Dropping unintialized memory could be considered a vulnerability, which is equivalent to use after free. I suggest submitting a ticket to Rust security advisory database just like #96 do. @Shnatsel @mbrubeck

@Shnatsel
Copy link

This bug never made it into a release. No dependencies were ever affected, so no need for an advisory.

We still have #156 outstanding though

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

No branches or pull requests

3 participants