summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2006-05-02 23:02:32 +0000
committerume <ume@FreeBSD.org>2006-05-02 23:02:32 +0000
commit90151bff3d423ce26ae4898fb406e1c64b4e5ff2 (patch)
tree2c4bb202d6091fb9c485296fba8a6f8203fae90e /usr.sbin
parent9474672d954d893aefe55a19ef2bbc11d20baa5d (diff)
downloadFreeBSD-src-90151bff3d423ce26ae4898fb406e1c64b4e5ff2.zip
FreeBSD-src-90151bff3d423ce26ae4898fb406e1c64b4e5ff2.tar.gz
Fix alignment problem on AMD64.
Reported by: Pascal Hofstee <caelian__at__gmail.com> Submitted by: Michael Bushkov <bushman__at__rsu.ru> Tested by: Pascal Hofstee <caelian__at__gmail.com>
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/cached/query.c14
-rw-r--r--usr.sbin/nscd/query.c14
2 files changed, 16 insertions, 12 deletions
diff --git a/usr.sbin/cached/query.c b/usr.sbin/cached/query.c
index 28882c3..947e93f 100644
--- a/usr.sbin/cached/query.c
+++ b/usr.sbin/cached/query.c
@@ -154,11 +154,12 @@ on_query_startup(struct query_state *qstate)
{
struct msghdr cred_hdr;
struct iovec iov;
+ struct cmsgcred *cred;
int elem_type;
struct {
struct cmsghdr hdr;
- struct cmsgcred creds;
+ char cred[CMSG_SPACE(sizeof(struct cmsgcred))];
} cmsg;
TRACE_IN(on_query_startup);
@@ -167,8 +168,8 @@ on_query_startup(struct query_state *qstate)
memset(&cred_hdr, 0, sizeof(struct msghdr));
cred_hdr.msg_iov = &iov;
cred_hdr.msg_iovlen = 1;
- cred_hdr.msg_control = &cmsg;
- cred_hdr.msg_controllen = sizeof(cmsg);
+ cred_hdr.msg_control = (caddr_t)&cmsg;
+ cred_hdr.msg_controllen = CMSG_LEN(sizeof(struct cmsgcred));
memset(&iov, 0, sizeof(struct iovec));
iov.iov_base = &elem_type;
@@ -179,15 +180,16 @@ on_query_startup(struct query_state *qstate)
return (-1);
}
- if (cmsg.hdr.cmsg_len != sizeof cmsg
+ if (cmsg.hdr.cmsg_len < CMSG_LEN(sizeof(struct cmsgcred))
|| cmsg.hdr.cmsg_level != SOL_SOCKET
|| cmsg.hdr.cmsg_type != SCM_CREDS) {
TRACE_OUT(on_query_startup);
return (-1);
}
- qstate->uid = cmsg.creds.cmcred_uid;
- qstate->gid = cmsg.creds.cmcred_gid;
+ cred = (struct cmsgcred *)CMSG_DATA(&cmsg);
+ qstate->uid = cred->cmcred_uid;
+ qstate->gid = cred->cmcred_gid;
#if defined(NS_CACHED_EID_CHECKING) || defined(NS_STRICT_CACHED_EID_CHECKING)
/*
diff --git a/usr.sbin/nscd/query.c b/usr.sbin/nscd/query.c
index 28882c3..947e93f 100644
--- a/usr.sbin/nscd/query.c
+++ b/usr.sbin/nscd/query.c
@@ -154,11 +154,12 @@ on_query_startup(struct query_state *qstate)
{
struct msghdr cred_hdr;
struct iovec iov;
+ struct cmsgcred *cred;
int elem_type;
struct {
struct cmsghdr hdr;
- struct cmsgcred creds;
+ char cred[CMSG_SPACE(sizeof(struct cmsgcred))];
} cmsg;
TRACE_IN(on_query_startup);
@@ -167,8 +168,8 @@ on_query_startup(struct query_state *qstate)
memset(&cred_hdr, 0, sizeof(struct msghdr));
cred_hdr.msg_iov = &iov;
cred_hdr.msg_iovlen = 1;
- cred_hdr.msg_control = &cmsg;
- cred_hdr.msg_controllen = sizeof(cmsg);
+ cred_hdr.msg_control = (caddr_t)&cmsg;
+ cred_hdr.msg_controllen = CMSG_LEN(sizeof(struct cmsgcred));
memset(&iov, 0, sizeof(struct iovec));
iov.iov_base = &elem_type;
@@ -179,15 +180,16 @@ on_query_startup(struct query_state *qstate)
return (-1);
}
- if (cmsg.hdr.cmsg_len != sizeof cmsg
+ if (cmsg.hdr.cmsg_len < CMSG_LEN(sizeof(struct cmsgcred))
|| cmsg.hdr.cmsg_level != SOL_SOCKET
|| cmsg.hdr.cmsg_type != SCM_CREDS) {
TRACE_OUT(on_query_startup);
return (-1);
}
- qstate->uid = cmsg.creds.cmcred_uid;
- qstate->gid = cmsg.creds.cmcred_gid;
+ cred = (struct cmsgcred *)CMSG_DATA(&cmsg);
+ qstate->uid = cred->cmcred_uid;
+ qstate->gid = cred->cmcred_gid;
#if defined(NS_CACHED_EID_CHECKING) || defined(NS_STRICT_CACHED_EID_CHECKING)
/*
OpenPOWER on IntegriCloud