Replace 'rescue nil' with DRY-violating versions :(
parent
85c5de07ec
commit
4966082de5
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue