[Python-checkins] python/dist/src/Lib ftplib.py,1.73,1.74

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Tue Apr 5 06:31:11 CEST 2005


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18972

Modified Files:
	ftplib.py 
Log Message:
SF bug #1168983:  ftplib.py string index out of range

* resp[:1] in '123' # after Py2.2, this allowed blank responses to pass.
* replace <> with !=
* provide a usage message for empty command line calls

Backport candidate.



Index: ftplib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/ftplib.py,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- ftplib.py	12 Feb 2004 17:35:06 -0000	1.73
+++ ftplib.py	5 Apr 2005 04:31:09 -0000	1.74
@@ -208,13 +208,13 @@
         if self.debugging: print '*resp*', self.sanitize(resp)
         self.lastresp = resp[:3]
         c = resp[:1]
+        if c in ('1', '2', '3'):
+            return resp
         if c == '4':
             raise error_temp, resp
         if c == '5':
             raise error_perm, resp
-        if c not in '123':
-            raise error_proto, resp
-        return resp
+        raise error_proto, resp
 
     def voidresp(self):
         """Expect a response beginning with '2'."""
@@ -582,17 +582,17 @@
     Raises error_proto if it does not contain '(|||port|)'
     Return ('host.addr.as.numbers', port#) tuple.'''
 
-    if resp[:3] <> '229':
+    if resp[:3] != '229':
         raise error_reply, resp
     left = resp.find('(')
     if left < 0: raise error_proto, resp
     right = resp.find(')', left + 1)
     if right < 0:
         raise error_proto, resp # should contain '(|||port|)'
-    if resp[left + 1] <> resp[right - 1]:
+    if resp[left + 1] != resp[right - 1]:
         raise error_proto, resp
     parts = resp[left + 1:right].split(resp[left+1])
-    if len(parts) <> 5:
+    if len(parts) != 5:
         raise error_proto, resp
     host = peer[0]
     port = int(parts[3])
@@ -755,7 +755,16 @@
 
 def test():
     '''Test program.
-    Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ...'''
+    Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ...
+
+    -d dir
+    -l list
+    -p password
+    '''
+
+    if len(sys.argv) < 2:
+        print test.__doc__
+        sys.exit(0)
 
     debugging = 0
     rcfile = None



More information about the Python-checkins mailing list