Skip to content

Incorrect CMSG functions on BSD #1210

@asomers

Description

@asomers

PR #1098 introduced Rust functions that duplicate the CMSG_FIRSTHDR, CMSG_NXTHDR, CMSG_DATA, CMSG_SPACE, and CMSG_LEN C macros. However, several of these are incorrect on BSD. It looks like the author wrote the Linux versions first, and then simply copied them into src/unix/bsd/mod.rs. For example, on both FreeBSD and OpenBSD CMSG_DATA is defined as

    pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut ::c_uchar {
        cmsg.offset(1) as *mut ::c_uchar
    }

even though the actual C macro is

#define CMSG_DATA(cmsg) \
        ((unsigned char *)(cmsg) + _ALIGN(sizeof(struct cmsghdr)))

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions