Bug - HTTP Client can call :shutdown on closed IO

When running Rex HTTP client calls across pivots, pivot sockets
can get closed by the remote server, resulting in a closed :conn
object within the client object. The clients :close method calls
self.conn.shutdown which raises an 'IOError closed stream' on what
is effectively a TCPSocket object in a closed state (under the Rex
abstraction).

Resolve by moving the self.conn.closed? check into the conditional
just above the :shutdown call, and remove if from the underlying
:close call as calling :close on an already closed TCPSocket
returns nil as opposed to throwing an exception like the :shutdown
method.
bug/bundler_fix
RageLtMan 2017-09-10 03:09:59 -04:00
parent faa84faf25
commit 8d60fdf9e7
1 changed files with 2 additions and 2 deletions

View File

@ -191,9 +191,9 @@ class Client
# Closes the connection to the remote server.
#
def close
if (self.conn)
if (self.conn and !self.conn.closed?)
self.conn.shutdown
self.conn.close unless self.conn.closed?
self.conn.close
end
self.conn = nil