diff options
Diffstat (limited to 'fs/cifs/connect.c')
| -rw-r--r-- | fs/cifs/connect.c | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 8d4657596301..18d3c7724d6e 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
| @@ -232,9 +232,8 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
| 232 | static int check2ndT2(struct smb_hdr *pSMB, unsigned int maxBufSize) | 232 | static int check2ndT2(struct smb_hdr *pSMB, unsigned int maxBufSize) |
| 233 | { | 233 | { |
| 234 | struct smb_t2_rsp *pSMBt; | 234 | struct smb_t2_rsp *pSMBt; |
| 235 | int total_data_size; | ||
| 236 | int data_in_this_rsp; | ||
| 237 | int remaining; | 235 | int remaining; |
| 236 | __u16 total_data_size, data_in_this_rsp; | ||
| 238 | 237 | ||
| 239 | if (pSMB->Command != SMB_COM_TRANSACTION2) | 238 | if (pSMB->Command != SMB_COM_TRANSACTION2) |
| 240 | return 0; | 239 | return 0; |
| @@ -248,8 +247,8 @@ static int check2ndT2(struct smb_hdr *pSMB, unsigned int maxBufSize) | |||
| 248 | 247 | ||
| 249 | pSMBt = (struct smb_t2_rsp *)pSMB; | 248 | pSMBt = (struct smb_t2_rsp *)pSMB; |
| 250 | 249 | ||
| 251 | total_data_size = le16_to_cpu(pSMBt->t2_rsp.TotalDataCount); | 250 | total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount); |
| 252 | data_in_this_rsp = le16_to_cpu(pSMBt->t2_rsp.DataCount); | 251 | data_in_this_rsp = get_unaligned_le16(&pSMBt->t2_rsp.DataCount); |
| 253 | 252 | ||
| 254 | remaining = total_data_size - data_in_this_rsp; | 253 | remaining = total_data_size - data_in_this_rsp; |
| 255 | 254 | ||
| @@ -275,21 +274,18 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB) | |||
| 275 | { | 274 | { |
| 276 | struct smb_t2_rsp *pSMB2 = (struct smb_t2_rsp *)psecond; | 275 | struct smb_t2_rsp *pSMB2 = (struct smb_t2_rsp *)psecond; |
| 277 | struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)pTargetSMB; | 276 | struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)pTargetSMB; |
| 278 | int total_data_size; | ||
| 279 | int total_in_buf; | ||
| 280 | int remaining; | ||
| 281 | int total_in_buf2; | ||
| 282 | char *data_area_of_target; | 277 | char *data_area_of_target; |
| 283 | char *data_area_of_buf2; | 278 | char *data_area_of_buf2; |
| 284 | __u16 byte_count; | 279 | int remaining; |
| 280 | __u16 byte_count, total_data_size, total_in_buf, total_in_buf2; | ||
| 285 | 281 | ||
| 286 | total_data_size = le16_to_cpu(pSMBt->t2_rsp.TotalDataCount); | 282 | total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount); |
| 287 | 283 | ||
| 288 | if (total_data_size != le16_to_cpu(pSMB2->t2_rsp.TotalDataCount)) { | 284 | if (total_data_size != |
| 285 | get_unaligned_le16(&pSMB2->t2_rsp.TotalDataCount)) | ||
| 289 | cFYI(1, "total data size of primary and secondary t2 differ"); | 286 | cFYI(1, "total data size of primary and secondary t2 differ"); |
| 290 | } | ||
| 291 | 287 | ||
| 292 | total_in_buf = le16_to_cpu(pSMBt->t2_rsp.DataCount); | 288 | total_in_buf = get_unaligned_le16(&pSMBt->t2_rsp.DataCount); |
| 293 | 289 | ||
| 294 | remaining = total_data_size - total_in_buf; | 290 | remaining = total_data_size - total_in_buf; |
| 295 | 291 | ||
| @@ -299,28 +295,28 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB) | |||
| 299 | if (remaining == 0) /* nothing to do, ignore */ | 295 | if (remaining == 0) /* nothing to do, ignore */ |
| 300 | return 0; | 296 | return 0; |
| 301 | 297 | ||
| 302 | total_in_buf2 = le16_to_cpu(pSMB2->t2_rsp.DataCount); | 298 | total_in_buf2 = get_unaligned_le16(&pSMB2->t2_rsp.DataCount); |
| 303 | if (remaining < total_in_buf2) { | 299 | if (remaining < total_in_buf2) { |
| 304 | cFYI(1, "transact2 2nd response contains too much data"); | 300 | cFYI(1, "transact2 2nd response contains too much data"); |
| 305 | } | 301 | } |
| 306 | 302 | ||
| 307 | /* find end of first SMB data area */ | 303 | /* find end of first SMB data area */ |
| 308 | data_area_of_target = (char *)&pSMBt->hdr.Protocol + | 304 | data_area_of_target = (char *)&pSMBt->hdr.Protocol + |
| 309 | le16_to_cpu(pSMBt->t2_rsp.DataOffset); | 305 | get_unaligned_le16(&pSMBt->t2_rsp.DataOffset); |
| 310 | /* validate target area */ | 306 | /* validate target area */ |
| 311 | 307 | ||
| 312 | data_area_of_buf2 = (char *) &pSMB2->hdr.Protocol + | 308 | data_area_of_buf2 = (char *)&pSMB2->hdr.Protocol + |
| 313 | le16_to_cpu(pSMB2->t2_rsp.DataOffset); | 309 | get_unaligned_le16(&pSMB2->t2_rsp.DataOffset); |
| 314 | 310 | ||
| 315 | data_area_of_target += total_in_buf; | 311 | data_area_of_target += total_in_buf; |
| 316 | 312 | ||
| 317 | /* copy second buffer into end of first buffer */ | 313 | /* copy second buffer into end of first buffer */ |
| 318 | memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2); | 314 | memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2); |
| 319 | total_in_buf += total_in_buf2; | 315 | total_in_buf += total_in_buf2; |
| 320 | pSMBt->t2_rsp.DataCount = cpu_to_le16(total_in_buf); | 316 | put_unaligned_le16(total_in_buf, &pSMBt->t2_rsp.DataCount); |
| 321 | byte_count = le16_to_cpu(BCC_LE(pTargetSMB)); | 317 | byte_count = get_bcc_le(pTargetSMB); |
| 322 | byte_count += total_in_buf2; | 318 | byte_count += total_in_buf2; |
| 323 | BCC_LE(pTargetSMB) = cpu_to_le16(byte_count); | 319 | put_bcc_le(byte_count, pTargetSMB); |
| 324 | 320 | ||
| 325 | byte_count = pTargetSMB->smb_buf_length; | 321 | byte_count = pTargetSMB->smb_buf_length; |
| 326 | byte_count += total_in_buf2; | 322 | byte_count += total_in_buf2; |
| @@ -334,7 +330,6 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB) | |||
| 334 | return 0; /* we are done */ | 330 | return 0; /* we are done */ |
| 335 | } else /* more responses to go */ | 331 | } else /* more responses to go */ |
| 336 | return 1; | 332 | return 1; |
| 337 | |||
| 338 | } | 333 | } |
| 339 | 334 | ||
| 340 | static void | 335 | static void |
| @@ -2937,8 +2932,8 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
| 2937 | TCONX_RSP *pSMBr; | 2932 | TCONX_RSP *pSMBr; |
| 2938 | unsigned char *bcc_ptr; | 2933 | unsigned char *bcc_ptr; |
| 2939 | int rc = 0; | 2934 | int rc = 0; |
| 2940 | int length, bytes_left; | 2935 | int length; |
| 2941 | __u16 count; | 2936 | __u16 bytes_left, count; |
| 2942 | 2937 | ||
| 2943 | if (ses == NULL) | 2938 | if (ses == NULL) |
| 2944 | return -EIO; | 2939 | return -EIO; |
| @@ -3032,7 +3027,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
| 3032 | tcon->need_reconnect = false; | 3027 | tcon->need_reconnect = false; |
| 3033 | tcon->tid = smb_buffer_response->Tid; | 3028 | tcon->tid = smb_buffer_response->Tid; |
| 3034 | bcc_ptr = pByteArea(smb_buffer_response); | 3029 | bcc_ptr = pByteArea(smb_buffer_response); |
| 3035 | bytes_left = BCC(smb_buffer_response); | 3030 | bytes_left = get_bcc(smb_buffer_response); |
| 3036 | length = strnlen(bcc_ptr, bytes_left - 2); | 3031 | length = strnlen(bcc_ptr, bytes_left - 2); |
| 3037 | if (smb_buffer->Flags2 & SMBFLG2_UNICODE) | 3032 | if (smb_buffer->Flags2 & SMBFLG2_UNICODE) |
| 3038 | is_unicode = true; | 3033 | is_unicode = true; |
