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

CString::from_vec_unchecked may not need to be unsafe #29918

Closed
huonw opened this issue Nov 18, 2015 · 2 comments
Closed

CString::from_vec_unchecked may not need to be unsafe #29918

huonw opened this issue Nov 18, 2015 · 2 comments
Labels
T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@huonw
Copy link
Member

huonw commented Nov 18, 2015

It's not obvious if one can cause memory unsafety with this function: when would an interior null be problematic?

Pointed out by @wthrowe in rust-lang/rfcs#1323 (comment).

@huonw huonw added I-nominated T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Nov 18, 2015
@bluss
Copy link
Member

bluss commented Nov 19, 2015

The question is if we want to drop the invariant that CString is guarding (no interior nulls). thestinger claims this causes security bugs. It's certainly in the category of problem prevention rather than direct memory safety.

@alexcrichton
Copy link
Member

The libs team discussed this during triage yesterday and the conclusion was that it is a static contract of the CString type that there are no interior nul bytes. It is considered suitable for types which provide these sorts of static contracts to use unsafe for methods that may violate this, so this fits within the conventions of the standard library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants