storeFile() bigger then max buffer size results in socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host
DjesLoc opened this issue · 11 comments
OS: Windows CE 7
Samba server (smbservice.dll)
When trying to storefiles bigger then the max buffer size (65520) the samba server disconnects.
Logging:
Received SMB message "SMB_COM_NEGOTIATE" (command:0x72 flags:0x98 flags2:0xC807 TID:0 UID:0)
SMB dialect negotiation successful (ExtendedSecurity:True)
SMB signing deactivated. SMB messages will NOT be signed.
port: 445
use_ntlm_v2=False
is_direct_tcp=True
Negotiation package:
Transmission Control Protocol, Src Port: 445, Dst Port: 58753, Seq: 1, Ack: 63, Len: 119
NetBIOS Session Service
SMB (Server Message Block Protocol)
SMB Header
Server Component: SMB
[Response to: 86]
[Time from request: 0.008563000 seconds]
SMB Command: Negotiate Protocol (0x72)
NT Status: STATUS_SUCCESS (0x00000000)
Flags: 0x98, Request/Response, Canonicalized Pathnames, Case Sensitivity
Flags2: 0xc807, Unicode Strings, Error Code Type, Extended Security Negotiation, Security Signatures, Extended Attributes, Long Names Allowed
Process ID High: 0
Signature: 0000000000000000
Reserved: 0000
Tree ID: 0
Process ID: 7028
User ID: 0
Multiplex ID: 1
Negotiate Protocol Response (0x72)
Word Count (WCT): 17
Selected Index: 0: NT LM 0.12
Security Mode: 0x03, Mode, Password
Max Mpx Count: 50
Max VCs: 1
Max Buffer Size: 65520
Max Raw Buffer: 65520
Session Key: 0x00000000
Capabilities: 0x800002dc, Unicode, Large Files, NT SMBs, NT Status Codes, Level 2 Oplocks, NT Find, Extended Security
.... .... .... .... .... .... .... ...0 = Raw Mode: Read Raw and Write Raw are not supported
.... .... .... .... .... .... .... ..0. = MPX Mode: Read Mpx and Write Mpx are not supported
.... .... .... .... .... .... .... .1.. = Unicode: Unicode strings are supported
.... .... .... .... .... .... .... 1... = Large Files: Large files are supported
.... .... .... .... .... .... ...1 .... = NT SMBs: NT SMBs are supported
.... .... .... .... .... .... ..0. .... = RPC Remote APIs: RPC remote APIs are not supported
.... .... .... .... .... .... .1.. .... = NT Status Codes: NT status codes are supported
.... .... .... .... .... .... 1... .... = Level 2 Oplocks: Level 2 oplocks are supported
.... .... .... .... .... ...0 .... .... = Lock and Read: Lock and Read is not supported
.... .... .... .... .... ..1. .... .... = NT Find: NT Find is supported
.... .... .... .... ...0 .... .... .... = Dfs: Dfs is not supported
.... .... .... .... ..0. .... .... .... = Infolevel Passthru: NT information level request passthrough is not supported
.... .... .... .... .0.. .... .... .... = Large ReadX: Large Read andX is not supported
.... .... .... .... 0... .... .... .... = Large WriteX: Large Write andX is not supported
.... .... .... ...0 .... .... .... .... = LWIO: LWIO ioctl/fsctl is not supported
.... .... 0... .... .... .... .... .... = UNIX: UNIX extensions are not supported
.... ..0. .... .... .... .... .... .... = Compressed Data: Compressed data transfer is not supported
..0. .... .... .... .... .... .... .... = Dynamic Reauth: Dynamic Reauth is not supported
1... .... .... .... .... .... .... .... = Extended Security: Extended security exchanges are supported
Internet Protocol Version 4, Src: 200.0.0.150, Dst: 200.0.0.100
Transmission Control Protocol, Src Port: 445, Dst Port: 59513, Seq: 120, Ack: 205, Len: 252
Source Port: 445
Destination Port: 59513
[Stream index: 2]
[TCP Segment Len: 252]
Sequence number: 120 (relative sequence number)
[Next sequence number: 372 (relative sequence number)]
Acknowledgment number: 205 (relative ack number)
0101 .... = Header Length: 20 bytes (5)
Flags: 0x018 (PSH, ACK)
Window size value: 256
[Calculated window size: 65536]
[Window size scaling factor: 256]
Checksum: 0xfd53 [unverified]
[Checksum Status: Unverified]
Urgent pointer: 0
[SEQ/ACK analysis]
[Timestamps]
TCP payload (252 bytes)
NetBIOS Session Service
SMB (Server Message Block Protocol)
SMB Header
Server Component: SMB
[Response to: 46]
[Time from request: 0.007805000 seconds]
SMB Command: Session Setup AndX (0x73)
NT Status: STATUS_MORE_PROCESSING_REQUIRED (0xc0000016)
Flags: 0x98, Request/Response, Canonicalized Pathnames, Case Sensitivity
Flags2: 0xc807, Unicode Strings, Error Code Type, Extended Security Negotiation, Security Signatures, Extended Attributes, Long Names Allowed
Process ID High: 0
Signature: 0000000000000000
Reserved: 0000
Tree ID: 0
Process ID: 9868
User ID: 7
Multiplex ID: 2
Session Setup AndX Response (0x73)
Word Count (WCT): 4
AndXCommand: No further commands (0xff)
Reserved: 00
AndXOffset: 0
Action: 0x0000
Security Blob Length: 161
Byte Count (BCC): 205
Security Blob: a1819e30819ba0030a0101a10c060a2b0601040182370202…
Native OS: Windows CE
Native LAN Manager: Windows CE
I don't have Windows CE in my testing environment, so I'm going to need your help to test the new base.py.
Please copy and rename the attached base.py to your pysmb/python3/smb folder, and re-run your script
base.py.txt (Remember to rename to base.py after downloading)
Tested with the new base.py.
Test is OK, no disconnect and file is fully stored.
@DjesLoc : Thanks for testing. Can I trouble you to test the following base.py again to see if it still works?
base.py.txt (Remember to rename to base.py after downloading)
This version doesn't work.
Same error as before socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host.
This version:
line 2539: data_len is 65504
In the working version:
line 2539: data_len is 65456
Thanks. Let me check through the specs again to determine the root cause of the issue. I should be able to do another release to fix this issue in a couple of days.
Fix has been released in pysmb 1.2.6
Thanks for the great work!
Just tested version 1.2.6.
Still the same error, socket error Errno 10054
line 2542 (base.py)
self.max_buffer_size = 65520
data_len = 65520
Can you remove the pysmb folder and reinstall again?
I suspect you are still using the bad base.py patch (as the line numbering should have changed in the new release)
The correct values should be:
line 2537 (base.py)
self.max_buffer_size = 65520
data_len = 65456
It was indeed the wrong version.
Tested, it works.
Thanks again!
Thanks again for your help in troubleshooting and testing the fix.
I will close this issue now. Feel free to re-open it or start a new one if there are other problems.