In ./source4/libcli/smb2/write.c, smb2_write always uses one SMB2 packet to send data to the server: it assumes the client has enough credits regardless of payload size.
But it fails to write 70000 bytes in a SMB2_WRITE request. The payload size determines the credits the client may have to consume in this SMB2_WRITE request. The following is taken from MS-SMB2 Section 18.104.22.168 Application Requests Writing to a File or Named Pipe:
If the client requests writing to a file and the server supports multi-credit operations, the CreditCharge field in the SMB2 header MUST be set to ( 1 + (Length – 1) / 65536 ).
There are two changes needs to made here:
1. The client should send SMB2_WRITE requests based on payload size and how many credits the server has granted to this client. (MS-SMB2 22.214.171.124, 126.96.36.199.5)
2. The client should set the CreditCharge in SMB2_HEADER if SMB 2.1 dialect is used. (MS-SMB2 2.2.1)
The same also applies to SMB2_READ requests.
Add metze to CC list since he does some work on SMB(2) and torture.
Metze, would you like to work on this?
Steven, would you like to fix the s4 SMB2 client library? This is also needed for s4 smbtorture.
Mathias I won't have time to do this in the near future (~1 month) but I do need
this functionality for tests I'll be writing soon. I'll leave this unassigned if
any one wants to take it in the mean time.
I'm working on improvements of the smb2 client library currently
should be fixed in master