Skip to content

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

Closed

Description

@huonw

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).

Activity

  1. bluss commented on Nov 19, 2015

    @bluss
    Contributor

    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.

  2. alexcrichton commented on Nov 19, 2015

    @alexcrichton
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-api[DEPRECATED; DO NOT USE]

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions