ruby_smb error when reading empty files
@cdelafuente-r7 is already working on this.
Since May 17, 2021.
Assessment
This issue has not been assessed yet.
Description
Ran into this error when testing some ascii/utf-8 issues.
If I ran examples/read_file.rb against an empty file, it would return the following errors:
➜ examples git:(master) ruby read_file.rb 192.168.215.190 <redacted> <redacted> Share 抽.txt 2
SMB2 : (0x00000000) STATUS_SUCCESS: The operation completed successfully.
Connected to \\192.168.215.190\Share successfully!
/Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/dispatcher/socket.rb:88:in `rescue in recv_packet': An error occurred reading from the Socket Connection reset by peer (RubySMB::Error::CommunicationError)
from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/dispatcher/socket.rb:63:in `recv_packet'
from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/client.rb:540:in `recv_packet'
from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/client.rb:467:in `send_recv'
from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/smb2/file.rb:92:in `close'
from read_file.rb:41:in `<main>'
/Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/dispatcher/socket.rb:70:in `read': Connection reset by peer (Errno::ECONNRESET)
from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/dispatcher/socket.rb:70:in `recv_packet'
from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/client.rb:540:in `recv_packet'
from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/client.rb:467:in `send_recv'
from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/smb2/file.rb:92:in `close'
from read_file.rb:41:in `<main>'
➜ examples git:(master)
This was tested against a Windows 8 & Windows 10 VM.
Found while attempting tor replicate this issue.
Steps to reproduce
How'd you do it?
- Run
examples/read_file.rbagainst an SMB share. e.g.
ruby examples/read_file.rb 192.168.2.5 <redacted> <redacted> share_test "Мой файл.txt" 2)
Were you following a specific guide/tutorial or reading documentation?
Found while attempting tor replicate this issue.
Expected behavior
Should return no errors and just a blank output, e.g.
➜ examples git:(master) ruby read_file.rb 192.168.215.190 <redacted> <redacted> Share 抽.txt 2
SMB2 : (0x00000000) STATUS_SUCCESS: The operation completed successfully.
Connected to \\192.168.215.190\Share successfully!
➜ examples git:(master)
Current behavior
Returns two errors:
RubySMB::Error::CommunicationError
Errno::ECONNRESET
➜ examples git:(master) ruby read_file.rb 192.168.215.190 <redacted> <redacted> Share 抽.txt 2
SMB2 : (0x00000000) STATUS_SUCCESS: The operation completed successfully.
Connected to \\192.168.215.190\Share successfully!
/Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/dispatcher/socket.rb:88:in `rescue in recv_packet': An error occurred reading from the Socket Connection reset by peer (RubySMB::Error::CommunicationError)
from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/dispatcher/socket.rb:63:in `recv_packet'
from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/client.rb:540:in `recv_packet'
from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/client.rb:467:in `send_recv'
from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/smb2/file.rb:92:in `close'
from read_file.rb:41:in `<main>'
/Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/dispatcher/socket.rb:70:in `read': Connection reset by peer (Errno::ECONNRESET)
from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/dispatcher/socket.rb:70:in `recv_packet'
from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/client.rb:540:in `recv_packet'
from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/client.rb:467:in `send_recv'
from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/smb2/file.rb:92:in `close'
from read_file.rb:41:in `<main>'
➜ examples git:(master)
- Dominant language
- Ruby
- Stars
- 86
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rapid7/ruby_smb
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
バグ
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
voxpupuli/puppet-epel#186 · 1 comment ·
-
external_created_at is no longer used for the message timestamp since the new message UI (v4.4.0) OpenBug Frontend
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
TheOdinProject/curriculum#31402 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100