Skip to content

Unsoundness in <SockRef as From<&AsRawFd>>::from #229

Closed

Description

@coolreader18

You can do something like:

let sock = socket2::SockRef::from(&-1);
assert!(Some(sock).is_none());

With the changes in #222

Activity

  1. Thomasdezeeuw commented on May 3, 2021

    @Thomasdezeeuw
    Collaborator

    This is the same problem as being discussed in #229, SockRef::from needs to ensure the RawFd is valid, but currently doesn't.

  2. Thomasdezeeuw commented on May 3, 2021

    @Thomasdezeeuw
    Collaborator

    Whoops I meant #218.

  3. coolreader18 commented on May 3, 2021

    @coolreader18
    ContributorAuthor

    Ah, sorry about that, shoulda checked.

  4. coolreader18 commented on May 3, 2021

    @coolreader18
    ContributorAuthor

    Oh, wait, I'll add this to that discussion, but this is actually unsound language-wise, not just questionably unsafe/non-private - because of the niche optimization from #222, you can create an invalid value in safe code.

  5. Thomasdezeeuw commented on May 3, 2021

    @Thomasdezeeuw
    Collaborator

    Oh, wait, I'll add this to that discussion, but this is actually unsound language-wise, not just questionably unsafe/non-private - because of the niche optimization from #222, you can create an invalid value in safe code.

    You're right using -1 is even worse, but as #222 is talking about a redesign I though it best to not have two concurrent threads talking about the same thing. But this is definitely blocking a v0.4.1 release (which would include #222).

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions