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

Major cmsg cleanup #1020

Merged
merged 6 commits into from
Feb 14, 2019
Merged

Major cmsg cleanup #1020

merged 6 commits into from
Feb 14, 2019

Commits on Feb 14, 2019

  1. Replace hand-rolled cmsg logic with libc's cmsg(3) functions.

    Our hand-rolled logic had subtle alignment bugs that caused
    test_scm_rights to fail on OpenBSD (and probably could cause problems on
    other platforms too).  Using cmsg(3) is much cleaner, shorter, and more
    portable.  No user-visible changes.
    asomers committed Feb 14, 2019
    Configuration menu
    Copy the full SHA
    ed1c90d View commit details
    Browse the repository at this point in the history
  2. Fix error handling of RecvMsg

    There were two problems:
    1) It would always return Ok, even on error
    2) It could panic if there was an error, because
       sockaddr_storage_to_addr would be called on uninitialized memory.
    asomers committed Feb 14, 2019
    Configuration menu
    Copy the full SHA
    368b9fe View commit details
    Browse the repository at this point in the history
  3. Replace CmsgSpace with a macro

    CmsgSpace had three problems:
    1) It would oversize buffers that expect multiple control messages
    2) It didn't use the libc CMSG_SPACE(3) macro, so it might actually
       undersize a buffer for a single control message.
    3) It could do bad things on drop, if you instantiate it with a type
       that implements Drop (which none of the currently supported
       ControlMessage types do).
    
    Fixes nix-rust#994
    asomers committed Feb 14, 2019
    Configuration menu
    Copy the full SHA
    e0f612d View commit details
    Browse the repository at this point in the history
  4. Fix misaligned references when using recvmsg with control messages

    On some platforms the alignment of cmsg_data could be less than the
    alignment of the messages that it contains.  That led to unaligned
    reads
    on those platforms.  This change fixes the issue by always copying the
    message contents into aligned objects.  The change is not 100%
    backwards
    compatible when using recvmsg.  Users may have to replace code like
    this:
    
    ```rust
    if let ControlMessage::ScmRights(&fds) = cmsg {
    ```
    
    with this:
    ```rust
    if let ControlMessageOwned::ScmRights(fds) = cmsg {
    ```
    
    Fixes nix-rust#999
    asomers committed Feb 14, 2019
    Configuration menu
    Copy the full SHA
    15ed5a5 View commit details
    Browse the repository at this point in the history
  5. Add CHANGELOG entry.

    asomers committed Feb 14, 2019
    Configuration menu
    Copy the full SHA
    2966dcd View commit details
    Browse the repository at this point in the history
  6. Enable IPv4PacketInfo and Ipv6PacketInfo on more OSes.

    This was an oversight from PR nix-rust#1002
    asomers committed Feb 14, 2019
    Configuration menu
    Copy the full SHA
    b5c4c7a View commit details
    Browse the repository at this point in the history