commit xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Author: Shaun Zinck <shaun.zinck@gmail.com>
Date:   Wed Mar 23 16:48:27 2011 -0500

    tcllib ftp: check for eof on socket while fetching data
    
    This alleviates problems when the ftp server doesn't speak strict
    RFC-959 , at least for the very last message sent.
    
    For example, this was causing Tcllib ftp code to have an infinite loop
    and eat 100% cpu.
    
    RETR blah
    150 Opening BINARY mode data connection for blah (180 bytes).
    226 Transfer complete.
    QUIT
    221-You have transferred 180 bytes in 1 files.
    
    ^^^ notice no "221 Goodbye."

diff --git a/ftp.tcl b/ftp.tcl
index xxxxxxx..xxxxxxx 100644
--- a/ftp.tcl
+++ b/ftp.tcl
@@ -274,6 +274,14 @@ proc ::ftp::StateHandler {s {sock ""}} {
 			# multi_line is not set if the bufline does not match the regexp,
 			# I.e. this keeps the '-' which started this around until the
 			# closing line does match and sets it to space.
+		    } elseif {$number == -1 && [eof $sock]} {
+			# The reply indicated a multi-line reply, but the
+			# socket was closed and there were no more lines.
+			# In that case, keep the current return values.
+
+			# This means the server isn't speaking strict rfc959.
+			# see section on multi-line replies
+			break
 		    }
 		}
 
