diff options
author | Damien Miller <djm@mindrot.org> | 2008-03-07 18:35:26 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2008-03-07 18:35:26 +1100 |
commit | c0c53c3114b652d30b8277d66fec82482bcde38d (patch) | |
tree | b36377d1860d0979ba617a8131a8173d952f659b /monitor_fdpass.c | |
parent | 7c29661471d0a7590ed41dec76661174c99b1c94 (diff) |
- deraadt@cvs.openbsd.org 2008/03/02 18:19:35
[monitor_fdpass.c]
use a union to ensure alignment of the cmsg (pay attention: various other
parts of the tree need this treatment too); ok djm
Diffstat (limited to 'monitor_fdpass.c')
-rw-r--r-- | monitor_fdpass.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/monitor_fdpass.c b/monitor_fdpass.c index a572302e8..fb00ab7ab 100644 --- a/monitor_fdpass.c +++ b/monitor_fdpass.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: monitor_fdpass.c,v 1.13 2007/09/04 03:21:03 djm Exp $ */ | 1 | /* $OpenBSD: monitor_fdpass.c,v 1.14 2008/03/02 18:19:35 deraadt Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright 2001 Niels Provos <provos@citi.umich.edu> | 3 | * Copyright 2001 Niels Provos <provos@citi.umich.edu> |
4 | * All rights reserved. | 4 | * All rights reserved. |
@@ -49,7 +49,10 @@ mm_send_fd(int sock, int fd) | |||
49 | char ch = '\0'; | 49 | char ch = '\0'; |
50 | ssize_t n; | 50 | ssize_t n; |
51 | #ifndef HAVE_ACCRIGHTS_IN_MSGHDR | 51 | #ifndef HAVE_ACCRIGHTS_IN_MSGHDR |
52 | char tmp[CMSG_SPACE(sizeof(int))]; | 52 | union { |
53 | struct cmsghdr hdr; | ||
54 | char tmp[CMSG_SPACE(sizeof(int))]; | ||
55 | } tmp; | ||
53 | struct cmsghdr *cmsg; | 56 | struct cmsghdr *cmsg; |
54 | #endif | 57 | #endif |
55 | 58 | ||
@@ -58,7 +61,7 @@ mm_send_fd(int sock, int fd) | |||
58 | msg.msg_accrights = (caddr_t)&fd; | 61 | msg.msg_accrights = (caddr_t)&fd; |
59 | msg.msg_accrightslen = sizeof(fd); | 62 | msg.msg_accrightslen = sizeof(fd); |
60 | #else | 63 | #else |
61 | msg.msg_control = (caddr_t)tmp; | 64 | msg.msg_control = (caddr_t)&tmp; |
62 | msg.msg_controllen = CMSG_LEN(sizeof(int)); | 65 | msg.msg_controllen = CMSG_LEN(sizeof(int)); |
63 | cmsg = CMSG_FIRSTHDR(&msg); | 66 | cmsg = CMSG_FIRSTHDR(&msg); |
64 | cmsg->cmsg_len = CMSG_LEN(sizeof(int)); | 67 | cmsg->cmsg_len = CMSG_LEN(sizeof(int)); |
@@ -100,7 +103,10 @@ mm_receive_fd(int sock) | |||
100 | char ch; | 103 | char ch; |
101 | int fd; | 104 | int fd; |
102 | #ifndef HAVE_ACCRIGHTS_IN_MSGHDR | 105 | #ifndef HAVE_ACCRIGHTS_IN_MSGHDR |
103 | char tmp[CMSG_SPACE(sizeof(int))]; | 106 | union { |
107 | char tmp[CMSG_SPACE(sizeof(int))]; | ||
108 | struct cmsghdr hdr; | ||
109 | } tmp; | ||
104 | struct cmsghdr *cmsg; | 110 | struct cmsghdr *cmsg; |
105 | #endif | 111 | #endif |
106 | 112 | ||
@@ -113,7 +119,7 @@ mm_receive_fd(int sock) | |||
113 | msg.msg_accrights = (caddr_t)&fd; | 119 | msg.msg_accrights = (caddr_t)&fd; |
114 | msg.msg_accrightslen = sizeof(fd); | 120 | msg.msg_accrightslen = sizeof(fd); |
115 | #else | 121 | #else |
116 | msg.msg_control = tmp; | 122 | msg.msg_control = &tmp; |
117 | msg.msg_controllen = sizeof(tmp); | 123 | msg.msg_controllen = sizeof(tmp); |
118 | #endif | 124 | #endif |
119 | 125 | ||