aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/connect.c
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2011-04-29 01:40:20 -0400
committerSteve French <sfrench@us.ibm.com>2011-05-19 10:10:51 -0400
commitbe8e3b0044a68e1f1002c432f6b40d290cf0701d (patch)
tree41f6a5e2ccf4bf03eb722030563490bbe46f0644 /fs/cifs/connect.c
parent9409ae58e0759d010b347e7b19ebc90ab5d4b98f (diff)
consistently use smb_buf_length as be32 for cifs (try 3)
There is one big endian field in the cifs protocol, the RFC1001 length, which cifs code (unlike in the smb2 code) had been handling as u32 until the last possible moment, when it was converted to be32 (its native form) before sending on the wire. To remove the last sparse endian warning, and to make this consistent with the smb2 implementation (which always treats the fields in their native size and endianness), convert all uses of smb_buf_length to be32. This version incorporates Christoph's comment about using be32_add_cpu, and fixes a typo in the second version of the patch. Signed-off-by: Steve French <sfrench@us.ibm.com> Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r--fs/cifs/connect.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index acd1e3c887e1..5d331cdd0b27 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -324,12 +324,12 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB)
324 return -EPROTO; 324 return -EPROTO;
325 put_bcc_le(byte_count, pTargetSMB); 325 put_bcc_le(byte_count, pTargetSMB);
326 326
327 byte_count = pTargetSMB->smb_buf_length; 327 byte_count = be32_to_cpu(pTargetSMB->smb_buf_length);
328 byte_count += total_in_buf2; 328 byte_count += total_in_buf2;
329 /* don't allow buffer to overflow */ 329 /* don't allow buffer to overflow */
330 if (byte_count > CIFSMaxBufSize) 330 if (byte_count > CIFSMaxBufSize)
331 return -ENOBUFS; 331 return -ENOBUFS;
332 pTargetSMB->smb_buf_length = byte_count; 332 pTargetSMB->smb_buf_length = cpu_to_be32(byte_count);
333 333
334 memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2); 334 memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2);
335 335
@@ -496,8 +496,7 @@ incomplete_rcv:
496 /* Note that FC 1001 length is big endian on the wire, 496 /* Note that FC 1001 length is big endian on the wire,
497 but we convert it here so it is always manipulated 497 but we convert it here so it is always manipulated
498 as host byte order */ 498 as host byte order */
499 pdu_length = be32_to_cpu((__force __be32)smb_buffer->smb_buf_length); 499 pdu_length = be32_to_cpu(smb_buffer->smb_buf_length);
500 smb_buffer->smb_buf_length = pdu_length;
501 500
502 cFYI(1, "rfc1002 length 0x%x", pdu_length+4); 501 cFYI(1, "rfc1002 length 0x%x", pdu_length+4);
503 502
@@ -2297,7 +2296,7 @@ ip_rfc1001_connect(struct TCP_Server_Info *server)
2297 smb_buf = (struct smb_hdr *)ses_init_buf; 2296 smb_buf = (struct smb_hdr *)ses_init_buf;
2298 2297
2299 /* sizeof RFC1002_SESSION_REQUEST with no scope */ 2298 /* sizeof RFC1002_SESSION_REQUEST with no scope */
2300 smb_buf->smb_buf_length = 0x81000044; 2299 smb_buf->smb_buf_length = cpu_to_be32(0x81000044);
2301 rc = smb_send(server, smb_buf, 0x44); 2300 rc = smb_send(server, smb_buf, 0x44);
2302 kfree(ses_init_buf); 2301 kfree(ses_init_buf);
2303 /* 2302 /*
@@ -3100,7 +3099,8 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
3100 bcc_ptr += strlen("?????"); 3099 bcc_ptr += strlen("?????");
3101 bcc_ptr += 1; 3100 bcc_ptr += 1;
3102 count = bcc_ptr - &pSMB->Password[0]; 3101 count = bcc_ptr - &pSMB->Password[0];
3103 pSMB->hdr.smb_buf_length += count; 3102 pSMB->hdr.smb_buf_length = cpu_to_be32(be32_to_cpu(
3103 pSMB->hdr.smb_buf_length) + count);
3104 pSMB->ByteCount = cpu_to_le16(count); 3104 pSMB->ByteCount = cpu_to_le16(count);
3105 3105
3106 rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, &length, 3106 rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, &length,