Replace 'rescue nil' with DRY-violating versions :(

bug/bundler_fix
HD Moore 2014-09-03 23:06:11 -05:00
parent 85c5de07ec
commit 4966082de5
1 changed files with 19 additions and 3 deletions

View File

@ -736,8 +736,16 @@ module Exploit::Remote::SMBServer
end end
def smb_stop(c) def smb_stop(c)
# Make sure the socket is closed # Make sure the socket is closed
c.close rescue nil begin
c.close
# Handle any number of errors that a double-close or failed shutdown can trigger
rescue ::IOError, ::EOFError,
::Errno::ECONNRESET, ::Errno::ENOTCONN, ::Errno::ECONNABORTED,
::Errno::ETIMEDOUT, ::Errno::ENETRESET, ::Errno::ESHUTDOWN
end
# Delete the state table entry # Delete the state table entry
@state.delete(c) @state.delete(c)
end end
@ -746,8 +754,16 @@ module Exploit::Remote::SMBServer
smb = @state[c] smb = @state[c]
smb[:data] ||= '' smb[:data] ||= ''
# Capture any low-level timeout exceptions to prevent it from bubbling buff = ''
buff = c.get_once(-1, 0.25) rescue nil begin
buff = c.get_once(-1, 0.25)
# Handle any number of errors that a read can trigger depending on socket state
rescue ::IOError, ::EOFError,
::Errno::ECONNRESET, ::Errno::ENOTCONN, ::Errno::ECONNABORTED,
::Errno::ETIMEDOUT, ::Errno::ENETRESET, ::Errno::ESHUTDOWN
smb_stop(c)
return
end
# The client said it had data, but lied, kill the session # The client said it had data, but lied, kill the session
unless buff and buff.length > 0 unless buff and buff.length > 0