From aa9ed6ebcdc13cc60a23959e2c2f3b666c09ec2c Mon Sep 17 00:00:00 2001 From: cgranleese-r7 Date: Fri, 15 Mar 2024 12:03:38 +0000 Subject: [PATCH] Adds EOFError raise for when a session is dead --- lib/ruby_smb/client.rb | 6 +++--- spec/lib/ruby_smb/client_spec.rb | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/ruby_smb/client.rb b/lib/ruby_smb/client.rb index 85b4be907..51d3d0934 100644 --- a/lib/ruby_smb/client.rb +++ b/lib/ruby_smb/client.rb @@ -578,9 +578,9 @@ def recv_packet(encrypt: false) raw_response = dispatcher.recv_packet rescue RubySMB::Error::CommunicationError => e if encrypt - raise RubySMB::Error::EncryptionError, "Communication error with the "\ - "remote host: #{e.message}. The server supports encryption but was "\ - "not able to handle the encrypted request." + raise e, "Communication error with the "\ + "remote host: #{e.message}. The server supports encryption and this error "\ + "may have been caused by encryption issues, but not always." else raise e end diff --git a/spec/lib/ruby_smb/client_spec.rb b/spec/lib/ruby_smb/client_spec.rb index 7ac7364c0..e9dcc7a51 100644 --- a/spec/lib/ruby_smb/client_spec.rb +++ b/spec/lib/ruby_smb/client_spec.rb @@ -471,9 +471,9 @@ it 'raises an EncryptionError exception if an error occurs while receiving the response' do allow(dispatcher).to receive(:recv_packet).and_raise(RubySMB::Error::CommunicationError) expect { client.recv_packet(encrypt: true) }.to raise_error( - RubySMB::Error::EncryptionError, + RubySMB::Error::CommunicationError, 'Communication error with the remote host: RubySMB::Error::CommunicationError. '\ - 'The server supports encryption but was not able to handle the encrypted request.' + 'The server supports encryption and this error may have been caused by encryption issues, but not always.' ) end @@ -2853,4 +2853,3 @@ end end end -