diff options
author | Steve French <sfrench@us.ibm.com> | 2007-07-07 15:25:05 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2007-07-07 15:25:05 -0400 |
commit | 790fe579f5006b72dfd2814f9263a73b0b455e81 (patch) | |
tree | 8d0749bb66bcd8993ae66101c6706e0ba432e155 /fs/cifs/sess.c | |
parent | 6dc0f87e351142e224b396f29b59527c4b2d834c (diff) |
[CIFS] more whitespace cleanup
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/sess.c')
-rw-r--r-- | fs/cifs/sess.c | 225 |
1 files changed, 114 insertions, 111 deletions
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index 758464630893..623c86cded24 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * SMB/CIFS session setup handling routines | 4 | * SMB/CIFS session setup handling routines |
5 | * | 5 | * |
6 | * Copyright (c) International Business Machines Corp., 2006 | 6 | * Copyright (c) International Business Machines Corp., 2006, 2007 |
7 | * Author(s): Steve French (sfrench@us.ibm.com) | 7 | * Author(s): Steve French (sfrench@us.ibm.com) |
8 | * | 8 | * |
9 | * This library is free software; you can redistribute it and/or modify | 9 | * This library is free software; you can redistribute it and/or modify |
@@ -31,7 +31,7 @@ | |||
31 | #include <linux/utsname.h> | 31 | #include <linux/utsname.h> |
32 | 32 | ||
33 | extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, | 33 | extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, |
34 | unsigned char *p24); | 34 | unsigned char *p24); |
35 | 35 | ||
36 | static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB) | 36 | static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB) |
37 | { | 37 | { |
@@ -45,13 +45,14 @@ static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB) | |||
45 | 45 | ||
46 | /* Now no need to set SMBFLG_CASELESS or obsolete CANONICAL PATH */ | 46 | /* Now no need to set SMBFLG_CASELESS or obsolete CANONICAL PATH */ |
47 | 47 | ||
48 | /* BB verify whether signing required on neg or just on auth frame | 48 | /* BB verify whether signing required on neg or just on auth frame |
49 | (and NTLM case) */ | 49 | (and NTLM case) */ |
50 | 50 | ||
51 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | | 51 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | |
52 | CAP_LARGE_WRITE_X | CAP_LARGE_READ_X; | 52 | CAP_LARGE_WRITE_X | CAP_LARGE_READ_X; |
53 | 53 | ||
54 | if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | 54 | if (ses->server->secMode & |
55 | (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) | ||
55 | pSMB->req.hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; | 56 | pSMB->req.hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; |
56 | 57 | ||
57 | if (ses->capabilities & CAP_UNICODE) { | 58 | if (ses->capabilities & CAP_UNICODE) { |
@@ -75,9 +76,9 @@ static __u32 cifs_ssetup_hdr(struct cifsSesInfo *ses, SESSION_SETUP_ANDX *pSMB) | |||
75 | } | 76 | } |
76 | 77 | ||
77 | static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses, | 78 | static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses, |
78 | const struct nls_table * nls_cp) | 79 | const struct nls_table *nls_cp) |
79 | { | 80 | { |
80 | char * bcc_ptr = *pbcc_area; | 81 | char *bcc_ptr = *pbcc_area; |
81 | int bytes_ret = 0; | 82 | int bytes_ret = 0; |
82 | 83 | ||
83 | /* BB FIXME add check that strings total less | 84 | /* BB FIXME add check that strings total less |
@@ -89,7 +90,7 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses, | |||
89 | bcc_ptr++; | 90 | bcc_ptr++; |
90 | } */ | 91 | } */ |
91 | /* copy user */ | 92 | /* copy user */ |
92 | if(ses->userName == NULL) { | 93 | if (ses->userName == NULL) { |
93 | /* null user mount */ | 94 | /* null user mount */ |
94 | *bcc_ptr = 0; | 95 | *bcc_ptr = 0; |
95 | *(bcc_ptr+1) = 0; | 96 | *(bcc_ptr+1) = 0; |
@@ -100,7 +101,7 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses, | |||
100 | bcc_ptr += 2 * bytes_ret; | 101 | bcc_ptr += 2 * bytes_ret; |
101 | bcc_ptr += 2; /* account for null termination */ | 102 | bcc_ptr += 2; /* account for null termination */ |
102 | /* copy domain */ | 103 | /* copy domain */ |
103 | if(ses->domainName == NULL) { | 104 | if (ses->domainName == NULL) { |
104 | /* Sending null domain better than using a bogus domain name (as | 105 | /* Sending null domain better than using a bogus domain name (as |
105 | we did briefly in 2.6.18) since server will use its default */ | 106 | we did briefly in 2.6.18) since server will use its default */ |
106 | *bcc_ptr = 0; | 107 | *bcc_ptr = 0; |
@@ -122,7 +123,7 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses, | |||
122 | bcc_ptr += 2; /* trailing null */ | 123 | bcc_ptr += 2; /* trailing null */ |
123 | 124 | ||
124 | bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS, | 125 | bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS, |
125 | 32, nls_cp); | 126 | 32, nls_cp); |
126 | bcc_ptr += 2 * bytes_ret; | 127 | bcc_ptr += 2 * bytes_ret; |
127 | bcc_ptr += 2; /* trailing null */ | 128 | bcc_ptr += 2; /* trailing null */ |
128 | 129 | ||
@@ -130,29 +131,29 @@ static void unicode_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses, | |||
130 | } | 131 | } |
131 | 132 | ||
132 | static void ascii_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses, | 133 | static void ascii_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses, |
133 | const struct nls_table * nls_cp) | 134 | const struct nls_table *nls_cp) |
134 | { | 135 | { |
135 | char * bcc_ptr = *pbcc_area; | 136 | char *bcc_ptr = *pbcc_area; |
136 | 137 | ||
137 | /* copy user */ | 138 | /* copy user */ |
138 | /* BB what about null user mounts - check that we do this BB */ | 139 | /* BB what about null user mounts - check that we do this BB */ |
139 | /* copy user */ | 140 | /* copy user */ |
140 | if(ses->userName == NULL) { | 141 | if (ses->userName == NULL) { |
141 | /* BB what about null user mounts - check that we do this BB */ | 142 | /* BB what about null user mounts - check that we do this BB */ |
142 | } else { /* 300 should be long enough for any conceivable user name */ | 143 | } else { /* 300 should be long enough for any conceivable user name */ |
143 | strncpy(bcc_ptr, ses->userName, 300); | 144 | strncpy(bcc_ptr, ses->userName, 300); |
144 | } | 145 | } |
145 | /* BB improve check for overflow */ | 146 | /* BB improve check for overflow */ |
146 | bcc_ptr += strnlen(ses->userName, 300); | 147 | bcc_ptr += strnlen(ses->userName, 300); |
147 | *bcc_ptr = 0; | 148 | *bcc_ptr = 0; |
148 | bcc_ptr++; /* account for null termination */ | 149 | bcc_ptr++; /* account for null termination */ |
149 | 150 | ||
150 | /* copy domain */ | 151 | /* copy domain */ |
151 | 152 | ||
152 | if(ses->domainName != NULL) { | 153 | if (ses->domainName != NULL) { |
153 | strncpy(bcc_ptr, ses->domainName, 256); | 154 | strncpy(bcc_ptr, ses->domainName, 256); |
154 | bcc_ptr += strnlen(ses->domainName, 256); | 155 | bcc_ptr += strnlen(ses->domainName, 256); |
155 | } /* else we will send a null domain name | 156 | } /* else we will send a null domain name |
156 | so the server will default to its own domain */ | 157 | so the server will default to its own domain */ |
157 | *bcc_ptr = 0; | 158 | *bcc_ptr = 0; |
158 | bcc_ptr++; | 159 | bcc_ptr++; |
@@ -167,19 +168,20 @@ static void ascii_ssetup_strings(char ** pbcc_area, struct cifsSesInfo *ses, | |||
167 | strcpy(bcc_ptr, CIFS_NETWORK_OPSYS); | 168 | strcpy(bcc_ptr, CIFS_NETWORK_OPSYS); |
168 | bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1; | 169 | bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1; |
169 | 170 | ||
170 | *pbcc_area = bcc_ptr; | 171 | *pbcc_area = bcc_ptr; |
171 | } | 172 | } |
172 | 173 | ||
173 | static int decode_unicode_ssetup(char ** pbcc_area, int bleft, struct cifsSesInfo *ses, | 174 | static int decode_unicode_ssetup(char **pbcc_area, int bleft, |
174 | const struct nls_table * nls_cp) | 175 | struct cifsSesInfo *ses, |
176 | const struct nls_table *nls_cp) | ||
175 | { | 177 | { |
176 | int rc = 0; | 178 | int rc = 0; |
177 | int words_left, len; | 179 | int words_left, len; |
178 | char * data = *pbcc_area; | 180 | char *data = *pbcc_area; |
179 | 181 | ||
180 | 182 | ||
181 | 183 | ||
182 | cFYI(1,("bleft %d",bleft)); | 184 | cFYI(1, ("bleft %d", bleft)); |
183 | 185 | ||
184 | 186 | ||
185 | /* SMB header is unaligned, so cifs servers word align start of | 187 | /* SMB header is unaligned, so cifs servers word align start of |
@@ -198,14 +200,14 @@ static int decode_unicode_ssetup(char ** pbcc_area, int bleft, struct cifsSesInf | |||
198 | /* We look for obvious messed up bcc or strings in response so we do not go off | 200 | /* We look for obvious messed up bcc or strings in response so we do not go off |
199 | the end since (at least) WIN2K and Windows XP have a major bug in not null | 201 | the end since (at least) WIN2K and Windows XP have a major bug in not null |
200 | terminating last Unicode string in response */ | 202 | terminating last Unicode string in response */ |
201 | if(len >= words_left) | 203 | if (len >= words_left) |
202 | return rc; | 204 | return rc; |
203 | 205 | ||
204 | if(ses->serverOS) | 206 | if (ses->serverOS) |
205 | kfree(ses->serverOS); | 207 | kfree(ses->serverOS); |
206 | /* UTF-8 string will not grow more than four times as big as UCS-16 */ | 208 | /* UTF-8 string will not grow more than four times as big as UCS-16 */ |
207 | ses->serverOS = kzalloc(4 * len, GFP_KERNEL); | 209 | ses->serverOS = kzalloc(4 * len, GFP_KERNEL); |
208 | if(ses->serverOS != NULL) { | 210 | if (ses->serverOS != NULL) { |
209 | cifs_strfromUCS_le(ses->serverOS, (__le16 *)data, len, | 211 | cifs_strfromUCS_le(ses->serverOS, (__le16 *)data, len, |
210 | nls_cp); | 212 | nls_cp); |
211 | } | 213 | } |
@@ -215,67 +217,68 @@ static int decode_unicode_ssetup(char ** pbcc_area, int bleft, struct cifsSesInf | |||
215 | /* save off server network operating system */ | 217 | /* save off server network operating system */ |
216 | len = UniStrnlen((wchar_t *) data, words_left); | 218 | len = UniStrnlen((wchar_t *) data, words_left); |
217 | 219 | ||
218 | if(len >= words_left) | 220 | if (len >= words_left) |
219 | return rc; | 221 | return rc; |
220 | 222 | ||
221 | if(ses->serverNOS) | 223 | if (ses->serverNOS) |
222 | kfree(ses->serverNOS); | 224 | kfree(ses->serverNOS); |
223 | ses->serverNOS = kzalloc(4 * len, GFP_KERNEL); /* BB this is wrong length FIXME BB */ | 225 | ses->serverNOS = kzalloc(4 * len, GFP_KERNEL); /* BB this is wrong length FIXME BB */ |
224 | if(ses->serverNOS != NULL) { | 226 | if (ses->serverNOS != NULL) { |
225 | cifs_strfromUCS_le(ses->serverNOS, (__le16 *)data, len, | 227 | cifs_strfromUCS_le(ses->serverNOS, (__le16 *)data, len, |
226 | nls_cp); | 228 | nls_cp); |
227 | if(strncmp(ses->serverNOS, "NT LAN Manager 4",16) == 0) { | 229 | if (strncmp(ses->serverNOS, "NT LAN Manager 4", 16) == 0) { |
228 | cFYI(1,("NT4 server")); | 230 | cFYI(1, ("NT4 server")); |
229 | ses->flags |= CIFS_SES_NT4; | 231 | ses->flags |= CIFS_SES_NT4; |
230 | } | 232 | } |
231 | } | 233 | } |
232 | data += 2 * (len + 1); | 234 | data += 2 * (len + 1); |
233 | words_left -= len + 1; | 235 | words_left -= len + 1; |
234 | 236 | ||
235 | /* save off server domain */ | 237 | /* save off server domain */ |
236 | len = UniStrnlen((wchar_t *) data, words_left); | 238 | len = UniStrnlen((wchar_t *) data, words_left); |
237 | 239 | ||
238 | if(len > words_left) | 240 | if (len > words_left) |
239 | return rc; | 241 | return rc; |
240 | 242 | ||
241 | if(ses->serverDomain) | 243 | if (ses->serverDomain) |
242 | kfree(ses->serverDomain); | 244 | kfree(ses->serverDomain); |
243 | ses->serverDomain = kzalloc(2 * (len + 1), GFP_KERNEL); /* BB FIXME wrong length */ | 245 | ses->serverDomain = kzalloc(2 * (len + 1), GFP_KERNEL); /* BB FIXME wrong length */ |
244 | if(ses->serverDomain != NULL) { | 246 | if (ses->serverDomain != NULL) { |
245 | cifs_strfromUCS_le(ses->serverDomain, (__le16 *)data, len, | 247 | cifs_strfromUCS_le(ses->serverDomain, (__le16 *)data, len, |
246 | nls_cp); | 248 | nls_cp); |
247 | ses->serverDomain[2*len] = 0; | 249 | ses->serverDomain[2*len] = 0; |
248 | ses->serverDomain[(2*len) + 1] = 0; | 250 | ses->serverDomain[(2*len) + 1] = 0; |
249 | } | 251 | } |
250 | data += 2 * (len + 1); | 252 | data += 2 * (len + 1); |
251 | words_left -= len + 1; | 253 | words_left -= len + 1; |
252 | 254 | ||
253 | cFYI(1,("words left: %d",words_left)); | 255 | cFYI(1, ("words left: %d", words_left)); |
254 | 256 | ||
255 | return rc; | 257 | return rc; |
256 | } | 258 | } |
257 | 259 | ||
258 | static int decode_ascii_ssetup(char ** pbcc_area, int bleft, struct cifsSesInfo *ses, | 260 | static int decode_ascii_ssetup(char **pbcc_area, int bleft, |
259 | const struct nls_table * nls_cp) | 261 | struct cifsSesInfo *ses, |
262 | const struct nls_table *nls_cp) | ||
260 | { | 263 | { |
261 | int rc = 0; | 264 | int rc = 0; |
262 | int len; | 265 | int len; |
263 | char * bcc_ptr = *pbcc_area; | 266 | char *bcc_ptr = *pbcc_area; |
264 | 267 | ||
265 | cFYI(1,("decode sessetup ascii. bleft %d", bleft)); | 268 | cFYI(1, ("decode sessetup ascii. bleft %d", bleft)); |
266 | 269 | ||
267 | len = strnlen(bcc_ptr, bleft); | 270 | len = strnlen(bcc_ptr, bleft); |
268 | if(len >= bleft) | 271 | if (len >= bleft) |
269 | return rc; | 272 | return rc; |
270 | 273 | ||
271 | if(ses->serverOS) | 274 | if (ses->serverOS) |
272 | kfree(ses->serverOS); | 275 | kfree(ses->serverOS); |
273 | 276 | ||
274 | ses->serverOS = kzalloc(len + 1, GFP_KERNEL); | 277 | ses->serverOS = kzalloc(len + 1, GFP_KERNEL); |
275 | if(ses->serverOS) | 278 | if (ses->serverOS) |
276 | strncpy(ses->serverOS, bcc_ptr, len); | 279 | strncpy(ses->serverOS, bcc_ptr, len); |
277 | if(strncmp(ses->serverOS, "OS/2",4) == 0) { | 280 | if (strncmp(ses->serverOS, "OS/2", 4) == 0) { |
278 | cFYI(1,("OS/2 server")); | 281 | cFYI(1, ("OS/2 server")); |
279 | ses->flags |= CIFS_SES_OS2; | 282 | ses->flags |= CIFS_SES_OS2; |
280 | } | 283 | } |
281 | 284 | ||
@@ -283,34 +286,34 @@ static int decode_ascii_ssetup(char ** pbcc_area, int bleft, struct cifsSesInfo | |||
283 | bleft -= len + 1; | 286 | bleft -= len + 1; |
284 | 287 | ||
285 | len = strnlen(bcc_ptr, bleft); | 288 | len = strnlen(bcc_ptr, bleft); |
286 | if(len >= bleft) | 289 | if (len >= bleft) |
287 | return rc; | 290 | return rc; |
288 | 291 | ||
289 | if(ses->serverNOS) | 292 | if (ses->serverNOS) |
290 | kfree(ses->serverNOS); | 293 | kfree(ses->serverNOS); |
291 | 294 | ||
292 | ses->serverNOS = kzalloc(len + 1, GFP_KERNEL); | 295 | ses->serverNOS = kzalloc(len + 1, GFP_KERNEL); |
293 | if(ses->serverNOS) | 296 | if (ses->serverNOS) |
294 | strncpy(ses->serverNOS, bcc_ptr, len); | 297 | strncpy(ses->serverNOS, bcc_ptr, len); |
295 | 298 | ||
296 | bcc_ptr += len + 1; | 299 | bcc_ptr += len + 1; |
297 | bleft -= len + 1; | 300 | bleft -= len + 1; |
298 | 301 | ||
299 | len = strnlen(bcc_ptr, bleft); | 302 | len = strnlen(bcc_ptr, bleft); |
300 | if(len > bleft) | 303 | if (len > bleft) |
301 | return rc; | 304 | return rc; |
302 | 305 | ||
303 | /* No domain field in LANMAN case. Domain is | 306 | /* No domain field in LANMAN case. Domain is |
304 | returned by old servers in the SMB negprot response */ | 307 | returned by old servers in the SMB negprot response */ |
305 | /* BB For newer servers which do not support Unicode, | 308 | /* BB For newer servers which do not support Unicode, |
306 | but thus do return domain here we could add parsing | 309 | but thus do return domain here we could add parsing |
307 | for it later, but it is not very important */ | 310 | for it later, but it is not very important */ |
308 | cFYI(1,("ascii: bytes left %d",bleft)); | 311 | cFYI(1, ("ascii: bytes left %d", bleft)); |
309 | 312 | ||
310 | return rc; | 313 | return rc; |
311 | } | 314 | } |
312 | 315 | ||
313 | int | 316 | int |
314 | CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, | 317 | CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, |
315 | const struct nls_table *nls_cp) | 318 | const struct nls_table *nls_cp) |
316 | { | 319 | { |
@@ -328,13 +331,13 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, | |||
328 | __u16 action; | 331 | __u16 action; |
329 | int bytes_remaining; | 332 | int bytes_remaining; |
330 | 333 | ||
331 | if(ses == NULL) | 334 | if (ses == NULL) |
332 | return -EINVAL; | 335 | return -EINVAL; |
333 | 336 | ||
334 | type = ses->server->secType; | 337 | type = ses->server->secType; |
335 | 338 | ||
336 | cFYI(1,("sess setup type %d",type)); | 339 | cFYI(1, ("sess setup type %d", type)); |
337 | if(type == LANMAN) { | 340 | if (type == LANMAN) { |
338 | #ifndef CONFIG_CIFS_WEAK_PW_HASH | 341 | #ifndef CONFIG_CIFS_WEAK_PW_HASH |
339 | /* LANMAN and plaintext are less secure and off by default. | 342 | /* LANMAN and plaintext are less secure and off by default. |
340 | So we make this explicitly be turned on in kconfig (in the | 343 | So we make this explicitly be turned on in kconfig (in the |
@@ -344,15 +347,15 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, | |||
344 | return -EOPNOTSUPP; | 347 | return -EOPNOTSUPP; |
345 | #endif | 348 | #endif |
346 | wct = 10; /* lanman 2 style sessionsetup */ | 349 | wct = 10; /* lanman 2 style sessionsetup */ |
347 | } else if((type == NTLM) || (type == NTLMv2)) { | 350 | } else if ((type == NTLM) || (type == NTLMv2)) { |
348 | /* For NTLMv2 failures eventually may need to retry NTLM */ | 351 | /* For NTLMv2 failures eventually may need to retry NTLM */ |
349 | wct = 13; /* old style NTLM sessionsetup */ | 352 | wct = 13; /* old style NTLM sessionsetup */ |
350 | } else /* same size for negotiate or auth, NTLMSSP or extended security */ | 353 | } else /* same size: negotiate or auth, NTLMSSP or extended security */ |
351 | wct = 12; | 354 | wct = 12; |
352 | 355 | ||
353 | rc = small_smb_init_no_tc(SMB_COM_SESSION_SETUP_ANDX, wct, ses, | 356 | rc = small_smb_init_no_tc(SMB_COM_SESSION_SETUP_ANDX, wct, ses, |
354 | (void **)&smb_buf); | 357 | (void **)&smb_buf); |
355 | if(rc) | 358 | if (rc) |
356 | return rc; | 359 | return rc; |
357 | 360 | ||
358 | pSMB = (SESSION_SETUP_ANDX *)smb_buf; | 361 | pSMB = (SESSION_SETUP_ANDX *)smb_buf; |
@@ -364,8 +367,8 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, | |||
364 | second part which will include the strings | 367 | second part which will include the strings |
365 | and rest of bcc area, in order to avoid having | 368 | and rest of bcc area, in order to avoid having |
366 | to do a large buffer 17K allocation */ | 369 | to do a large buffer 17K allocation */ |
367 | iov[0].iov_base = (char *)pSMB; | 370 | iov[0].iov_base = (char *)pSMB; |
368 | iov[0].iov_len = smb_buf->smb_buf_length + 4; | 371 | iov[0].iov_len = smb_buf->smb_buf_length + 4; |
369 | 372 | ||
370 | /* 2000 big enough to fit max user, domain, NOS name etc. */ | 373 | /* 2000 big enough to fit max user, domain, NOS name etc. */ |
371 | str_area = kmalloc(2000, GFP_KERNEL); | 374 | str_area = kmalloc(2000, GFP_KERNEL); |
@@ -373,18 +376,18 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, | |||
373 | 376 | ||
374 | ses->flags &= ~CIFS_SES_LANMAN; | 377 | ses->flags &= ~CIFS_SES_LANMAN; |
375 | 378 | ||
376 | if(type == LANMAN) { | 379 | if (type == LANMAN) { |
377 | #ifdef CONFIG_CIFS_WEAK_PW_HASH | 380 | #ifdef CONFIG_CIFS_WEAK_PW_HASH |
378 | char lnm_session_key[CIFS_SESS_KEY_SIZE]; | 381 | char lnm_session_key[CIFS_SESS_KEY_SIZE]; |
379 | 382 | ||
380 | /* no capabilities flags in old lanman negotiation */ | 383 | /* no capabilities flags in old lanman negotiation */ |
381 | 384 | ||
382 | pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_SESS_KEY_SIZE); | 385 | pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_SESS_KEY_SIZE); |
383 | /* BB calculate hash with password */ | 386 | /* BB calculate hash with password */ |
384 | /* and copy into bcc */ | 387 | /* and copy into bcc */ |
385 | 388 | ||
386 | calc_lanman_hash(ses, lnm_session_key); | 389 | calc_lanman_hash(ses, lnm_session_key); |
387 | ses->flags |= CIFS_SES_LANMAN; | 390 | ses->flags |= CIFS_SES_LANMAN; |
388 | /* #ifdef CONFIG_CIFS_DEBUG2 | 391 | /* #ifdef CONFIG_CIFS_DEBUG2 |
389 | cifs_dump_mem("cryptkey: ",ses->server->cryptKey, | 392 | cifs_dump_mem("cryptkey: ",ses->server->cryptKey, |
390 | CIFS_SESS_KEY_SIZE); | 393 | CIFS_SESS_KEY_SIZE); |
@@ -397,10 +400,10 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, | |||
397 | changed to do higher than lanman dialect and | 400 | changed to do higher than lanman dialect and |
398 | we reconnected would we ever calc signing_key? */ | 401 | we reconnected would we ever calc signing_key? */ |
399 | 402 | ||
400 | cFYI(1,("Negotiating LANMAN setting up strings")); | 403 | cFYI(1, ("Negotiating LANMAN setting up strings")); |
401 | /* Unicode not allowed for LANMAN dialects */ | 404 | /* Unicode not allowed for LANMAN dialects */ |
402 | ascii_ssetup_strings(&bcc_ptr, ses, nls_cp); | 405 | ascii_ssetup_strings(&bcc_ptr, ses, nls_cp); |
403 | #endif | 406 | #endif |
404 | } else if (type == NTLM) { | 407 | } else if (type == NTLM) { |
405 | char ntlm_session_key[CIFS_SESS_KEY_SIZE]; | 408 | char ntlm_session_key[CIFS_SESS_KEY_SIZE]; |
406 | 409 | ||
@@ -414,33 +417,33 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, | |||
414 | SMBNTencrypt(ses->password, ses->server->cryptKey, | 417 | SMBNTencrypt(ses->password, ses->server->cryptKey, |
415 | ntlm_session_key); | 418 | ntlm_session_key); |
416 | 419 | ||
417 | if(first_time) /* should this be moved into common code | 420 | if (first_time) /* should this be moved into common code |
418 | with similar ntlmv2 path? */ | 421 | with similar ntlmv2 path? */ |
419 | cifs_calculate_mac_key(ses->server->mac_signing_key, | 422 | cifs_calculate_mac_key(ses->server->mac_signing_key, |
420 | ntlm_session_key, ses->password); | 423 | ntlm_session_key, ses->password); |
421 | /* copy session key */ | 424 | /* copy session key */ |
422 | 425 | ||
423 | memcpy(bcc_ptr, (char *)ntlm_session_key,CIFS_SESS_KEY_SIZE); | 426 | memcpy(bcc_ptr, (char *)ntlm_session_key, CIFS_SESS_KEY_SIZE); |
424 | bcc_ptr += CIFS_SESS_KEY_SIZE; | 427 | bcc_ptr += CIFS_SESS_KEY_SIZE; |
425 | memcpy(bcc_ptr, (char *)ntlm_session_key,CIFS_SESS_KEY_SIZE); | 428 | memcpy(bcc_ptr, (char *)ntlm_session_key, CIFS_SESS_KEY_SIZE); |
426 | bcc_ptr += CIFS_SESS_KEY_SIZE; | 429 | bcc_ptr += CIFS_SESS_KEY_SIZE; |
427 | if(ses->capabilities & CAP_UNICODE) { | 430 | if (ses->capabilities & CAP_UNICODE) { |
428 | /* unicode strings must be word aligned */ | 431 | /* unicode strings must be word aligned */ |
429 | if (iov[0].iov_len % 2) { | 432 | if (iov[0].iov_len % 2) { |
430 | *bcc_ptr = 0; | 433 | *bcc_ptr = 0; |
431 | bcc_ptr++; | 434 | bcc_ptr++; |
432 | } | 435 | } |
433 | unicode_ssetup_strings(&bcc_ptr, ses, nls_cp); | 436 | unicode_ssetup_strings(&bcc_ptr, ses, nls_cp); |
434 | } else | 437 | } else |
435 | ascii_ssetup_strings(&bcc_ptr, ses, nls_cp); | 438 | ascii_ssetup_strings(&bcc_ptr, ses, nls_cp); |
436 | } else if (type == NTLMv2) { | 439 | } else if (type == NTLMv2) { |
437 | char * v2_sess_key = | 440 | char *v2_sess_key = |
438 | kmalloc(sizeof(struct ntlmv2_resp), GFP_KERNEL); | 441 | kmalloc(sizeof(struct ntlmv2_resp), GFP_KERNEL); |
439 | 442 | ||
440 | /* BB FIXME change all users of v2_sess_key to | 443 | /* BB FIXME change all users of v2_sess_key to |
441 | struct ntlmv2_resp */ | 444 | struct ntlmv2_resp */ |
442 | 445 | ||
443 | if(v2_sess_key == NULL) { | 446 | if (v2_sess_key == NULL) { |
444 | cifs_small_buf_release(smb_buf); | 447 | cifs_small_buf_release(smb_buf); |
445 | return -ENOMEM; | 448 | return -ENOMEM; |
446 | } | 449 | } |
@@ -456,8 +459,8 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, | |||
456 | 459 | ||
457 | /* calculate session key */ | 460 | /* calculate session key */ |
458 | setup_ntlmv2_rsp(ses, v2_sess_key, nls_cp); | 461 | setup_ntlmv2_rsp(ses, v2_sess_key, nls_cp); |
459 | if(first_time) /* should this be moved into common code | 462 | if (first_time) /* should this be moved into common code |
460 | with similar ntlmv2 path? */ | 463 | with similar ntlmv2 path? */ |
461 | /* cifs_calculate_ntlmv2_mac_key(ses->server->mac_signing_key, | 464 | /* cifs_calculate_ntlmv2_mac_key(ses->server->mac_signing_key, |
462 | response BB FIXME, v2_sess_key); */ | 465 | response BB FIXME, v2_sess_key); */ |
463 | 466 | ||
@@ -468,8 +471,8 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, | |||
468 | memcpy(bcc_ptr, (char *)v2_sess_key, sizeof(struct ntlmv2_resp)); | 471 | memcpy(bcc_ptr, (char *)v2_sess_key, sizeof(struct ntlmv2_resp)); |
469 | bcc_ptr += sizeof(struct ntlmv2_resp); | 472 | bcc_ptr += sizeof(struct ntlmv2_resp); |
470 | kfree(v2_sess_key); | 473 | kfree(v2_sess_key); |
471 | if(ses->capabilities & CAP_UNICODE) { | 474 | if (ses->capabilities & CAP_UNICODE) { |
472 | if(iov[0].iov_len % 2) { | 475 | if (iov[0].iov_len % 2) { |
473 | *bcc_ptr = 0; | 476 | *bcc_ptr = 0; |
474 | } bcc_ptr++; | 477 | } bcc_ptr++; |
475 | unicode_ssetup_strings(&bcc_ptr, ses, nls_cp); | 478 | unicode_ssetup_strings(&bcc_ptr, ses, nls_cp); |
@@ -488,20 +491,20 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, | |||
488 | BCC_LE(smb_buf) = cpu_to_le16(count); | 491 | BCC_LE(smb_buf) = cpu_to_le16(count); |
489 | 492 | ||
490 | iov[1].iov_base = str_area; | 493 | iov[1].iov_base = str_area; |
491 | iov[1].iov_len = count; | 494 | iov[1].iov_len = count; |
492 | rc = SendReceive2(xid, ses, iov, 2 /* num_iovecs */, &resp_buf_type, 0); | 495 | rc = SendReceive2(xid, ses, iov, 2 /* num_iovecs */, &resp_buf_type, 0); |
493 | /* SMB request buf freed in SendReceive2 */ | 496 | /* SMB request buf freed in SendReceive2 */ |
494 | 497 | ||
495 | cFYI(1,("ssetup rc from sendrecv2 is %d",rc)); | 498 | cFYI(1, ("ssetup rc from sendrecv2 is %d", rc)); |
496 | if(rc) | 499 | if (rc) |
497 | goto ssetup_exit; | 500 | goto ssetup_exit; |
498 | 501 | ||
499 | pSMB = (SESSION_SETUP_ANDX *)iov[0].iov_base; | 502 | pSMB = (SESSION_SETUP_ANDX *)iov[0].iov_base; |
500 | smb_buf = (struct smb_hdr *)iov[0].iov_base; | 503 | smb_buf = (struct smb_hdr *)iov[0].iov_base; |
501 | 504 | ||
502 | if((smb_buf->WordCount != 3) && (smb_buf->WordCount != 4)) { | 505 | if ((smb_buf->WordCount != 3) && (smb_buf->WordCount != 4)) { |
503 | rc = -EIO; | 506 | rc = -EIO; |
504 | cERROR(1,("bad word count %d", smb_buf->WordCount)); | 507 | cERROR(1, ("bad word count %d", smb_buf->WordCount)); |
505 | goto ssetup_exit; | 508 | goto ssetup_exit; |
506 | } | 509 | } |
507 | action = le16_to_cpu(pSMB->resp.Action); | 510 | action = le16_to_cpu(pSMB->resp.Action); |
@@ -514,20 +517,20 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, | |||
514 | bytes_remaining = BCC(smb_buf); | 517 | bytes_remaining = BCC(smb_buf); |
515 | bcc_ptr = pByteArea(smb_buf); | 518 | bcc_ptr = pByteArea(smb_buf); |
516 | 519 | ||
517 | if(smb_buf->WordCount == 4) { | 520 | if (smb_buf->WordCount == 4) { |
518 | __u16 blob_len; | 521 | __u16 blob_len; |
519 | blob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength); | 522 | blob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength); |
520 | bcc_ptr += blob_len; | 523 | bcc_ptr += blob_len; |
521 | if(blob_len > bytes_remaining) { | 524 | if (blob_len > bytes_remaining) { |
522 | cERROR(1,("bad security blob length %d", blob_len)); | 525 | cERROR(1, ("bad security blob length %d", blob_len)); |
523 | rc = -EINVAL; | 526 | rc = -EINVAL; |
524 | goto ssetup_exit; | 527 | goto ssetup_exit; |
525 | } | 528 | } |
526 | bytes_remaining -= blob_len; | 529 | bytes_remaining -= blob_len; |
527 | } | 530 | } |
528 | 531 | ||
529 | /* BB check if Unicode and decode strings */ | 532 | /* BB check if Unicode and decode strings */ |
530 | if(smb_buf->Flags2 & SMBFLG2_UNICODE) | 533 | if (smb_buf->Flags2 & SMBFLG2_UNICODE) |
531 | rc = decode_unicode_ssetup(&bcc_ptr, bytes_remaining, | 534 | rc = decode_unicode_ssetup(&bcc_ptr, bytes_remaining, |
532 | ses, nls_cp); | 535 | ses, nls_cp); |
533 | else | 536 | else |
@@ -535,10 +538,10 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time, | |||
535 | 538 | ||
536 | ssetup_exit: | 539 | ssetup_exit: |
537 | kfree(str_area); | 540 | kfree(str_area); |
538 | if(resp_buf_type == CIFS_SMALL_BUFFER) { | 541 | if (resp_buf_type == CIFS_SMALL_BUFFER) { |
539 | cFYI(1,("ssetup freeing small buf %p", iov[0].iov_base)); | 542 | cFYI(1, ("ssetup freeing small buf %p", iov[0].iov_base)); |
540 | cifs_small_buf_release(iov[0].iov_base); | 543 | cifs_small_buf_release(iov[0].iov_base); |
541 | } else if(resp_buf_type == CIFS_LARGE_BUFFER) | 544 | } else if (resp_buf_type == CIFS_LARGE_BUFFER) |
542 | cifs_buf_release(iov[0].iov_base); | 545 | cifs_buf_release(iov[0].iov_base); |
543 | 546 | ||
544 | return rc; | 547 | return rc; |