Skip to content

Commit 8d60fdf

Browse files
author
RageLtMan
committed
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.
1 parent faa84fa commit 8d60fdf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/rex/proto/http/client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ def connect(t = -1)
191191
# Closes the connection to the remote server.
192192
#
193193
def close
194-
if (self.conn)
194+
if (self.conn and !self.conn.closed?)
195195
self.conn.shutdown
196-
self.conn.close unless self.conn.closed?
196+
self.conn.close
197197
end
198198

199199
self.conn = nil

0 commit comments

Comments
 (0)