summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-12 16:40:08 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-12 16:40:08 +0000
commitb76dad515e0039c27bc935ddfcbbd7474d32675a (patch)
tree895a4f00762717098496bebae9c30b817ce1c48b /lib
parent070afc692e463f7cb5b2d1955d3405e5c53fb88d (diff)
merge revision(s) 51046: [Backport #11260]
* lib/net/ftp.rb (makeport): close the TCPServer when sending the port fails. * test/net/ftp/test_ftp.rb: test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@51556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/net/ftp.rb11
1 files changed, 3 insertions, 8 deletions
diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb
index c64bb5c682..f513ca6ee8 100644
--- a/lib/net/ftp.rb
+++ b/lib/net/ftp.rb
@@ -377,15 +377,9 @@ module Net
end
private :sendport
- # Constructs a TCPServer socket, and sends it the PORT command
- #
- # Returns the constructed TCPServer socket
+ # Constructs a TCPServer socket
def makeport # :nodoc:
- sock = TCPServer.open(@sock.addr[3], 0)
- port = sock.addr[1]
- host = sock.addr[3]
- sendport(host, port)
- return sock
+ TCPServer.open(@sock.addr[3], 0)
end
private :makeport
@@ -421,6 +415,7 @@ module Net
else
sock = makeport
begin
+ sendport(sock.addr[3], sock.addr[1])
if @resume and rest_offset
resp = sendcmd("REST " + rest_offset.to_s)
if resp[0] != ?3