[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [hurd-amd64] ibus test failures
From: |
Diego Nieto Cid |
Subject: |
Re: [hurd-amd64] ibus test failures |
Date: |
Wed, 1 Jan 2025 20:07:04 +0000 |
On Wed, Jan 01, 2025 at 06:51:47PM +0100, Samuel Thibault wrote:
> >
> > /* Structure used for storage of ancillary data object information. */
> > struct cmsghdr
> > {
> > socklen_t cmsg_len; /* Length of data in cmsg_data plus
> > length
> > of cmsghdr structure. */
>
> That's the correct type according to posix:
>
> ./basedefs/sys_socket.h.html:<tt>socklen_t cmsg_len </tt> Data byte count,
> including the <b>cmsghdr</b>. <tt>
>
Ok, but we are giving unaligned data pointers with the current implementation
of CMSG_DATA.
GLib has the following code to parse control messages
control_message = g_socket_control_message_deserialize (cmsg->cmsg_level,
cmsg->cmsg_type,
cmsg->cmsg_len - ((char *)CMSG_DATA (cmsg) - (char *)cmsg),
the third parameter is the size of the ancillary data. And CMSG_DATA should
align the header structure size for it to work (bacause cmsg_len was computed
with CMSG_LEN which aligns the header).
Something like the definition below could work, (except for when felxarr are
available):
#define CMSG_DATA(cmsg) ((unsigned char *) (cmsg) + (CMSG_ALIGN (sizeof
(struct cmsghdr))))