File: | obj-scan-build/trans/passwordServer.c |
Location: | line 192, column 12 |
Description: | Value stored to 'msgh_simple' during its initialization is never read |
1 | /* Module password */ |
2 | |
3 | #ifndef _GNU_SOURCE1 |
4 | #define _GNU_SOURCE1 1 |
5 | #endif |
6 | |
7 | #define EXPORT_BOOLEAN |
8 | #include <mach/boolean.h> |
9 | #include <mach/kern_return.h> |
10 | #include <mach/message.h> |
11 | #include <mach/mig_errors.h> |
12 | #include <mach/mig_support.h> |
13 | |
14 | #ifndef mig_internalstatic |
15 | #define mig_internalstatic static |
16 | #endif |
17 | |
18 | #ifndef mig_external |
19 | #define mig_external |
20 | #endif |
21 | |
22 | #ifndef mig_unlikely |
23 | #define mig_unlikely(X)__builtin_expect (!! (X), 0) __builtin_expect (!! (X), 0) |
24 | #endif |
25 | |
26 | #ifndef TypeCheck1 |
27 | #define TypeCheck1 1 |
28 | #endif |
29 | |
30 | #ifndef UseExternRCSId1 |
31 | #define UseExternRCSId1 1 |
32 | #endif |
33 | |
34 | #define BAD_TYPECHECK(type, check)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; } )), 0) mig_unlikely (({\__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; } )), 0) |
35 | union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; } )), 0) |
36 | _t.t = *(type); _c.t = *(check);_t.w != _c.w; }))__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; } )), 0) |
37 | #define msgh_request_portmsgh_local_port msgh_local_port |
38 | #define MACH_MSGH_BITS_REQUEST(bits)(((bits) & 0x0000ff00) >> 8) MACH_MSGH_BITS_LOCAL(bits)(((bits) & 0x0000ff00) >> 8) |
39 | #define msgh_reply_portmsgh_remote_port msgh_remote_port |
40 | #define MACH_MSGH_BITS_REPLY(bits)((bits) & 0x000000ff) MACH_MSGH_BITS_REMOTE(bits)((bits) & 0x000000ff) |
41 | |
42 | #include "../libtrivfs/mig-decls.h" |
43 | #include <hurd/ports.h> |
44 | #include <mach/std_types.h> |
45 | #include <mach/mach_types.h> |
46 | #include <device/device_types.h> |
47 | #include <device/net_status.h> |
48 | #include <sys/types.h> |
49 | #include <sys/stat.h> |
50 | #include <sys/statfs.h> |
51 | #include <sys/resource.h> |
52 | #include <sys/utsname.h> |
53 | #include <hurd/hurd_types.h> |
54 | |
55 | /* Routine password_check_user */ |
56 | mig_internalstatic void _Xpassword_check_user |
57 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
58 | { |
59 | typedef struct { |
60 | mach_msg_header_t Head; |
61 | mach_msg_type_t userType; |
62 | uid_t user; |
63 | mach_msg_type_t pwType; |
64 | string_t pw; |
65 | } Request; |
66 | |
67 | typedef struct { |
68 | mach_msg_header_t Head; |
69 | mach_msg_type_t RetCodeType; |
70 | kern_return_t RetCode; |
71 | mach_msg_type_t authType; |
72 | mach_port_t auth; |
73 | } Reply; |
74 | |
75 | Request *In0P = (Request *) InHeadP; |
76 | Reply *OutP = (Reply *) OutHeadP; |
77 | mig_external kern_return_t S_password_check_user |
78 | (trivfs_protid_t server, uid_t user, string_t pw, mach_port_t *auth, mach_msg_type_name_t *authPoly); |
79 | |
80 | boolean_t msgh_simple = msgh_simple; |
81 | const mach_msg_type_t userCheck = { |
82 | /* msgt_name = */ 2, |
83 | /* msgt_size = */ 32, |
84 | /* msgt_number = */ 1, |
85 | /* msgt_inline = */ TRUE((boolean_t) 1), |
86 | /* msgt_longform = */ FALSE((boolean_t) 0), |
87 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
88 | /* msgt_unused = */ 0 |
89 | }; |
90 | |
91 | const mach_msg_type_t pwCheck = { |
92 | /* msgt_name = */ MACH_MSG_TYPE_STRING_C12, |
93 | /* msgt_size = */ 8, |
94 | /* msgt_number = */ 1024, |
95 | /* msgt_inline = */ TRUE((boolean_t) 1), |
96 | /* msgt_longform = */ FALSE((boolean_t) 0), |
97 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
98 | /* msgt_unused = */ 0 |
99 | }; |
100 | |
101 | const mach_msg_type_t authType = { |
102 | /* msgt_name = */ -1, |
103 | /* msgt_size = */ 32, |
104 | /* msgt_number = */ 1, |
105 | /* msgt_inline = */ TRUE((boolean_t) 1), |
106 | /* msgt_longform = */ FALSE((boolean_t) 0), |
107 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
108 | /* msgt_unused = */ 0 |
109 | }; |
110 | |
111 | trivfs_protid_t server; |
112 | mach_msg_type_name_t authPoly; |
113 | |
114 | #if TypeCheck1 |
115 | if (mig_unlikely ((In0P->Head.msgh_size != 1060) ||__builtin_expect (!! ((In0P->Head.msgh_size != 1060) || (In0P ->Head.msgh_bits & 0x80000000U)), 0) |
116 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 1060) || (In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
117 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
118 | #endif /* TypeCheck */ |
119 | |
120 | #if TypeCheck1 |
121 | if (BAD_TYPECHECK(&In0P->userType, &userCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->userType); _c.t = *(& userCheck);_t.w != _c.w; })), 0)) |
122 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
123 | #endif /* TypeCheck */ |
124 | |
125 | #if TypeCheck1 |
126 | if (BAD_TYPECHECK(&In0P->pwType, &pwCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->pwType); _c.t = *(&pwCheck );_t.w != _c.w; })), 0)) |
127 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
128 | #endif /* TypeCheck */ |
129 | |
130 | if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23) |
131 | server = trivfs_begin_using_protid_payload(In0P->Head.msgh_protected_payload); |
132 | else |
133 | server = trivfs_begin_using_protid(In0P->Head.msgh_request_portmsgh_local_port); |
134 | |
135 | OutP->RetCode = S_password_check_user(server, In0P->user, In0P->pw, &OutP->auth, &authPoly); |
136 | trivfs_end_using_protid(server); |
137 | if (OutP->RetCode != KERN_SUCCESS0) |
138 | return; |
139 | |
140 | msgh_simple = TRUE((boolean_t) 1); |
141 | OutP->Head.msgh_size = 40; |
142 | |
143 | OutP->authType = authType; |
144 | |
145 | if (MACH_MSG_TYPE_PORT_ANY(authPoly)(((authPoly) >= 16) && ((authPoly) <= 21))) |
146 | msgh_simple = FALSE((boolean_t) 0); |
147 | |
148 | OutP->authType.msgt_name = authPoly; |
149 | |
150 | if (!msgh_simple) |
151 | OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U; |
152 | } |
153 | |
154 | /* Default implementation of S_password_check_user */ |
155 | #ifdef MIG_EOPNOTSUPP |
156 | kern_return_t __attribute__ ((weak)) |
157 | S_password_check_user |
158 | ( |
159 | trivfs_protid_t server, |
160 | uid_t user, |
161 | string_t pw, |
162 | mach_port_t *auth, |
163 | mach_msg_type_name_t *authPoly |
164 | ) { return MIG_EOPNOTSUPP; } |
165 | #endif /* MIG_EOPNOTSUPP */ |
166 | |
167 | /* Routine password_check_group */ |
168 | mig_internalstatic void _Xpassword_check_group |
169 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
170 | { |
171 | typedef struct { |
172 | mach_msg_header_t Head; |
173 | mach_msg_type_t groupType; |
174 | uid_t group; |
175 | mach_msg_type_t pwType; |
176 | string_t pw; |
177 | } Request; |
178 | |
179 | typedef struct { |
180 | mach_msg_header_t Head; |
181 | mach_msg_type_t RetCodeType; |
182 | kern_return_t RetCode; |
183 | mach_msg_type_t authType; |
184 | mach_port_t auth; |
185 | } Reply; |
186 | |
187 | Request *In0P = (Request *) InHeadP; |
188 | Reply *OutP = (Reply *) OutHeadP; |
189 | mig_external kern_return_t S_password_check_group |
190 | (trivfs_protid_t server, uid_t group, string_t pw, mach_port_t *auth, mach_msg_type_name_t *authPoly); |
191 | |
192 | boolean_t msgh_simple = msgh_simple; |
Value stored to 'msgh_simple' during its initialization is never read | |
193 | const mach_msg_type_t groupCheck = { |
194 | /* msgt_name = */ 2, |
195 | /* msgt_size = */ 32, |
196 | /* msgt_number = */ 1, |
197 | /* msgt_inline = */ TRUE((boolean_t) 1), |
198 | /* msgt_longform = */ FALSE((boolean_t) 0), |
199 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
200 | /* msgt_unused = */ 0 |
201 | }; |
202 | |
203 | const mach_msg_type_t pwCheck = { |
204 | /* msgt_name = */ MACH_MSG_TYPE_STRING_C12, |
205 | /* msgt_size = */ 8, |
206 | /* msgt_number = */ 1024, |
207 | /* msgt_inline = */ TRUE((boolean_t) 1), |
208 | /* msgt_longform = */ FALSE((boolean_t) 0), |
209 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
210 | /* msgt_unused = */ 0 |
211 | }; |
212 | |
213 | const mach_msg_type_t authType = { |
214 | /* msgt_name = */ -1, |
215 | /* msgt_size = */ 32, |
216 | /* msgt_number = */ 1, |
217 | /* msgt_inline = */ TRUE((boolean_t) 1), |
218 | /* msgt_longform = */ FALSE((boolean_t) 0), |
219 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
220 | /* msgt_unused = */ 0 |
221 | }; |
222 | |
223 | trivfs_protid_t server; |
224 | mach_msg_type_name_t authPoly; |
225 | |
226 | #if TypeCheck1 |
227 | if (mig_unlikely ((In0P->Head.msgh_size != 1060) ||__builtin_expect (!! ((In0P->Head.msgh_size != 1060) || (In0P ->Head.msgh_bits & 0x80000000U)), 0) |
228 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 1060) || (In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
229 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
230 | #endif /* TypeCheck */ |
231 | |
232 | #if TypeCheck1 |
233 | if (BAD_TYPECHECK(&In0P->groupType, &groupCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->groupType); _c.t = *(& groupCheck);_t.w != _c.w; })), 0)) |
234 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
235 | #endif /* TypeCheck */ |
236 | |
237 | #if TypeCheck1 |
238 | if (BAD_TYPECHECK(&In0P->pwType, &pwCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->pwType); _c.t = *(&pwCheck );_t.w != _c.w; })), 0)) |
239 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
240 | #endif /* TypeCheck */ |
241 | |
242 | if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23) |
243 | server = trivfs_begin_using_protid_payload(In0P->Head.msgh_protected_payload); |
244 | else |
245 | server = trivfs_begin_using_protid(In0P->Head.msgh_request_portmsgh_local_port); |
246 | |
247 | OutP->RetCode = S_password_check_group(server, In0P->group, In0P->pw, &OutP->auth, &authPoly); |
248 | trivfs_end_using_protid(server); |
249 | if (OutP->RetCode != KERN_SUCCESS0) |
250 | return; |
251 | |
252 | msgh_simple = TRUE((boolean_t) 1); |
253 | OutP->Head.msgh_size = 40; |
254 | |
255 | OutP->authType = authType; |
256 | |
257 | if (MACH_MSG_TYPE_PORT_ANY(authPoly)(((authPoly) >= 16) && ((authPoly) <= 21))) |
258 | msgh_simple = FALSE((boolean_t) 0); |
259 | |
260 | OutP->authType.msgt_name = authPoly; |
261 | |
262 | if (!msgh_simple) |
263 | OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U; |
264 | } |
265 | |
266 | /* Default implementation of S_password_check_group */ |
267 | #ifdef MIG_EOPNOTSUPP |
268 | kern_return_t __attribute__ ((weak)) |
269 | S_password_check_group |
270 | ( |
271 | trivfs_protid_t server, |
272 | uid_t group, |
273 | string_t pw, |
274 | mach_port_t *auth, |
275 | mach_msg_type_name_t *authPoly |
276 | ) { return MIG_EOPNOTSUPP; } |
277 | #endif /* MIG_EOPNOTSUPP */ |
278 | |
279 | mig_routine_t password_server_routines[] = { |
280 | _Xpassword_check_user, |
281 | _Xpassword_check_group, |
282 | }; |
283 | |
284 | mig_external boolean_t password_server |
285 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
286 | { |
287 | mach_msg_header_t *InP = InHeadP; |
288 | mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; |
289 | |
290 | const mach_msg_type_t RetCodeType = { |
291 | /* msgt_name = */ MACH_MSG_TYPE_INTEGER_322, |
292 | /* msgt_size = */ 32, |
293 | /* msgt_number = */ 1, |
294 | /* msgt_inline = */ TRUE((boolean_t) 1), |
295 | /* msgt_longform = */ FALSE((boolean_t) 0), |
296 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
297 | /* msgt_unused = */ 0 |
298 | }; |
299 | |
300 | mig_routine_t routine; |
301 | |
302 | OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0)((((InP->msgh_bits) & 0x000000ff)) | ((0) << 8)); |
303 | OutP->Head.msgh_size = sizeof *OutP; |
304 | OutP->Head.msgh_remote_port = InP->msgh_reply_portmsgh_remote_port; |
305 | OutP->Head.msgh_local_port = MACH_PORT_NULL((mach_port_t) 0); |
306 | OutP->Head.msgh_seqno = 0; |
307 | OutP->Head.msgh_id = InP->msgh_id + 100; |
308 | |
309 | OutP->RetCodeType = RetCodeType; |
310 | |
311 | if ((InP->msgh_id > 38001) || (InP->msgh_id < 38000) || |
312 | ((routine = password_server_routines[InP->msgh_id - 38000]) == 0)) { |
313 | OutP->RetCode = MIG_BAD_ID-303; |
314 | return FALSE((boolean_t) 0); |
315 | } |
316 | (*routine) (InP, &OutP->Head); |
317 | return TRUE((boolean_t) 1); |
318 | } |
319 | |
320 | mig_external mig_routine_t password_server_routine |
321 | (const mach_msg_header_t *InHeadP) |
322 | { |
323 | int msgh_id; |
324 | |
325 | msgh_id = InHeadP->msgh_id - 38000; |
326 | |
327 | if ((msgh_id > 1) || (msgh_id < 0)) |
328 | return 0; |
329 | |
330 | return password_server_routines[msgh_id]; |
331 | } |
332 |