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

Comments

Projects
None yet
3 participants
@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).

@bluss

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Member

alexcrichton commented Nov 19, 2015

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
You can’t perform that action at this time.