Commit cdf92942 authored by Alexandre Julliard's avatar Alexandre Julliard

Use the proper size for the cmsg_fd structure on 64-bit plaforms.

parent 1476116b
......@@ -74,9 +74,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(server);
/* data structure used to pass an fd with sendmsg/recvmsg */
struct cmsg_fd
{
int len; /* size of structure */
struct
{
size_t len; /* size of structure */
int level; /* SOL_SOCKET */
int type; /* SCM_RIGHTS */
} header;
int fd; /* fd to pass */
};
#endif /* HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS */
......@@ -339,12 +342,12 @@ void wine_server_send_fd( int fd )
msghdr.msg_accrights = (void *)&fd;
msghdr.msg_accrightslen = sizeof(fd);
#else /* HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS */
cmsg.len = sizeof(cmsg);
cmsg.level = SOL_SOCKET;
cmsg.type = SCM_RIGHTS;
cmsg.header.len = sizeof(cmsg.header) + sizeof(fd);
cmsg.header.level = SOL_SOCKET;
cmsg.header.type = SCM_RIGHTS;
cmsg.fd = fd;
msghdr.msg_control = &cmsg;
msghdr.msg_controllen = sizeof(cmsg);
msghdr.msg_controllen = sizeof(cmsg.header) + sizeof(fd);
msghdr.msg_flags = 0;
#endif /* HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS */
......@@ -382,12 +385,12 @@ static int receive_fd( obj_handle_t *handle )
struct msghdr msghdr;
struct cmsg_fd cmsg;
cmsg.len = sizeof(cmsg);
cmsg.level = SOL_SOCKET;
cmsg.type = SCM_RIGHTS;
cmsg.header.len = sizeof(cmsg.header) + sizeof(fd);
cmsg.header.level = SOL_SOCKET;
cmsg.header.type = SCM_RIGHTS;
cmsg.fd = -1;
msghdr.msg_control = &cmsg;
msghdr.msg_controllen = sizeof(cmsg);
msghdr.msg_controllen = sizeof(cmsg.header) + sizeof(fd);
msghdr.msg_flags = 0;
#endif /* HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS */
......
......@@ -122,12 +122,15 @@ static struct msghdr msghdr;
#ifndef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS
struct cmsg_fd
{
int len; /* size of structure */
struct
{
size_t len; /* size of structure */
int level; /* SOL_SOCKET */
int type; /* SCM_RIGHTS */
} header;
int fd; /* fd to pass */
};
static struct cmsg_fd cmsg = { sizeof(cmsg), SOL_SOCKET, SCM_RIGHTS, -1 };
static struct cmsg_fd cmsg = { { sizeof(cmsg.header) + sizeof(cmsg.fd), SOL_SOCKET, SCM_RIGHTS }, -1 };
#endif /* HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS */
/* complain about a protocol error and terminate the client connection */
......@@ -350,7 +353,7 @@ int receive_fd( struct process *process )
msghdr.msg_accrights = (void *)&fd;
#else /* HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS */
msghdr.msg_control = &cmsg;
msghdr.msg_controllen = sizeof(cmsg);
msghdr.msg_controllen = sizeof(cmsg.header) + sizeof(fd);
cmsg.fd = -1;
#endif /* HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS */
......@@ -420,7 +423,7 @@ int send_client_fd( struct process *process, int fd, obj_handle_t handle )
msghdr.msg_accrights = (void *)&fd;
#else /* HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS */
msghdr.msg_control = &cmsg;
msghdr.msg_controllen = sizeof(cmsg);
msghdr.msg_controllen = sizeof(cmsg.header) + sizeof(fd);
cmsg.fd = fd;
#endif /* HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment