From 12c6b6683f8a2036578e87c659afa79d3a1d68a9 Mon Sep 17 00:00:00 2001 From: George McCollister Date: Mon, 15 Mar 2010 13:54:53 -0500 Subject: Fixed buffer alignment in exchange_credentials(). buf needs to be 32 bit aligned on ARM. Also made the fix on the server side. Signed-off-by: George McCollister --- src/responder/common/responder_common.c | 10 +++++++--- src/sss_client/common.c | 14 +++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c index f4de3a79..156f0c84 100644 --- a/src/responder/common/responder_common.c +++ b/src/responder/common/responder_common.c @@ -157,7 +157,11 @@ static void cred_handler(struct cli_ctx *cctx, char action) struct iovec iov; struct cmsghdr *cmsg; struct ucred *creds; - char buf[CMSG_SPACE(sizeof(struct ucred))]; + /* buf must be aligned on some architectures. */ + union ubuf { + int align; + char buf[CMSG_SPACE(sizeof(struct ucred))]; + } u; char dummy='s'; int enable=1; @@ -178,8 +182,8 @@ static void cred_handler(struct cli_ctx *cctx, char action) msg.msg_iov = &iov; msg.msg_iovlen = 1; - msg.msg_control = buf; - msg.msg_controllen = sizeof(buf); + msg.msg_control = u.buf; + msg.msg_controllen = sizeof(u.buf); switch (action) { case 'r': diff --git a/src/sss_client/common.c b/src/sss_client/common.c index f1c8d185..07b9d0d9 100644 --- a/src/sss_client/common.c +++ b/src/sss_client/common.c @@ -63,7 +63,11 @@ static int exchange_credentials(void) struct cmsghdr *cmsg; struct iovec iov; char dummy='a'; - char buf[CMSG_SPACE(sizeof(struct ucred))]; + /* buf must be aligned on some architectures. */ + union ubuf { + int align; + char buf[CMSG_SPACE(sizeof(struct ucred))]; + } u; struct ucred *creds; int enable = 1; struct pollfd pfd; @@ -83,8 +87,8 @@ static int exchange_credentials(void) msg.msg_iov = &iov; msg.msg_iovlen = 1; - msg.msg_control = buf; - msg.msg_controllen = sizeof(buf); + msg.msg_control = u.buf; + msg.msg_controllen = sizeof(u.buf); cmsg = CMSG_FIRSTHDR(&msg); cmsg->cmsg_level = SOL_SOCKET; @@ -118,8 +122,8 @@ static int exchange_credentials(void) msg.msg_iov = &iov; msg.msg_iovlen = 1; - msg.msg_control = buf; - msg.msg_controllen = sizeof(buf); + msg.msg_control = u.buf; + msg.msg_controllen = sizeof(u.buf); pfd.fd = sss_cli_sd; pfd.events = POLLIN; -- cgit