]> granicus.if.org Git - python/commitdiff
Patch #1359217: Ignore 2xx response before 150 response.
authorMartin v. Löwis <martin@v.loewis.de>
Sun, 12 Nov 2006 18:48:30 +0000 (18:48 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Sun, 12 Nov 2006 18:48:30 +0000 (18:48 +0000)
Lib/ftplib.py
Misc/NEWS

index 937ee4e8f03fa1c911196f03be53fbfb89dc41d5..9cb67dd55691654df0368f86db2b13ae45b2b810 100644 (file)
@@ -325,6 +325,14 @@ class FTP:
             if rest is not None:
                 self.sendcmd("REST %s" % rest)
             resp = self.sendcmd(cmd)
+            # Some servers apparently send a 200 reply to
+            # a LIST or STOR command, before the 150 reply
+            # (and way before the 226 reply). This seems to
+            # be in violation of the protocol (which only allows
+            # 1xx or error messages for LIST), so we just discard
+            # this response.
+            if resp[0] == '2':
+               resp = self.getresp()
             if resp[0] != '1':
                 raise error_reply, resp
         else:
@@ -332,6 +340,9 @@ class FTP:
             if rest is not None:
                 self.sendcmd("REST %s" % rest)
             resp = self.sendcmd(cmd)
+            # See above.
+            if resp[0] == '2':
+               resp = self.getresp()
             if resp[0] != '1':
                 raise error_reply, resp
             conn, sockaddr = sock.accept()
index d41d7cc30f0a77bc33d99f8191e995a0ad2d3225..d632043b49efe9da89aef0de76176afa25aed9bd 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -99,6 +99,9 @@ Extension Modules
 Library
 -------
 
+- Patch #1359217: Process 2xx response in an ftplib transfer
+  that precedes an 1xx response.
+
 - Patch #1060577: Extract list of RPM files from spec file in
   bdist_rpm