diff options
Diffstat (limited to 'fs/cifs/cifssmb.c')
-rw-r--r-- | fs/cifs/cifssmb.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 575b2281518d..f72a61df3c68 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -1072,7 +1072,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon, | |||
1072 | if (bytes_sent > count) | 1072 | if (bytes_sent > count) |
1073 | bytes_sent = count; | 1073 | bytes_sent = count; |
1074 | pSMB->DataOffset = | 1074 | pSMB->DataOffset = |
1075 | cpu_to_le16(offsetof(struct smb_com_write_req,Data) - 4); | 1075 | cpu_to_le16(offsetof(struct smb_com_write_req,Data) - 4); |
1076 | if(buf) | 1076 | if(buf) |
1077 | memcpy(pSMB->Data,buf,bytes_sent); | 1077 | memcpy(pSMB->Data,buf,bytes_sent); |
1078 | else if(ubuf) { | 1078 | else if(ubuf) { |
@@ -1080,20 +1080,23 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon, | |||
1080 | cifs_buf_release(pSMB); | 1080 | cifs_buf_release(pSMB); |
1081 | return -EFAULT; | 1081 | return -EFAULT; |
1082 | } | 1082 | } |
1083 | } else { | 1083 | } else if (count != 0) { |
1084 | /* No buffer */ | 1084 | /* No buffer */ |
1085 | cifs_buf_release(pSMB); | 1085 | cifs_buf_release(pSMB); |
1086 | return -EINVAL; | 1086 | return -EINVAL; |
1087 | } /* else setting file size with write of zero bytes */ | ||
1088 | if(wct == 14) | ||
1089 | byte_count = bytes_sent + 1; /* pad */ | ||
1090 | else /* wct == 12 */ { | ||
1091 | byte_count = bytes_sent + 5; /* bigger pad, smaller smb hdr */ | ||
1087 | } | 1092 | } |
1088 | |||
1089 | byte_count = bytes_sent + 1 /* pad */ ; /* BB fix this for sends > 64K */ | ||
1090 | pSMB->DataLengthLow = cpu_to_le16(bytes_sent & 0xFFFF); | 1093 | pSMB->DataLengthLow = cpu_to_le16(bytes_sent & 0xFFFF); |
1091 | pSMB->DataLengthHigh = cpu_to_le16(bytes_sent >> 16); | 1094 | pSMB->DataLengthHigh = cpu_to_le16(bytes_sent >> 16); |
1092 | pSMB->hdr.smb_buf_length += bytes_sent+1; | 1095 | pSMB->hdr.smb_buf_length += byte_count; |
1093 | 1096 | ||
1094 | if(wct == 14) | 1097 | if(wct == 14) |
1095 | pSMB->ByteCount = cpu_to_le16(byte_count); | 1098 | pSMB->ByteCount = cpu_to_le16(byte_count); |
1096 | else { /* old style write has byte count 4 bytes earlier */ | 1099 | else { /* old style write has byte count 4 bytes earlier so 4 bytes pad */ |
1097 | struct smb_com_writex_req * pSMBW = | 1100 | struct smb_com_writex_req * pSMBW = |
1098 | (struct smb_com_writex_req *)pSMB; | 1101 | (struct smb_com_writex_req *)pSMB; |
1099 | pSMBW->ByteCount = cpu_to_le16(byte_count); | 1102 | pSMBW->ByteCount = cpu_to_le16(byte_count); |