cpython: 44ac81e6d584 (original) (raw)

Mercurial > cpython

changeset 86510:44ac81e6d584 2.7

Issue #16038: CVE-2013-1752: ftplib: Limit amount of data read by limiting the call to readline(). Original patch by Michał Jastrzębski and Giampaolo Rodola. [#16038]

Serhiy Storchaka storchaka@gmail.com
date Sun, 20 Oct 2013 16:57:07 +0300
parents 625ece68d79a
children 0592dc076bb7
files Lib/ftplib.py Lib/test/test_ftplib.py Misc/NEWS
diffstat 3 files changed, 46 insertions(+), 7 deletions(-)[+] [-] Lib/ftplib.py 27 Lib/test/test_ftplib.py 22 Misc/NEWS 4

line wrap: on

line diff

--- a/Lib/ftplib.py +++ b/Lib/ftplib.py @@ -55,6 +55,8 @@ MSG_OOB = 0x1

The standard FTP server control port

FTP_PORT = 21 +# The sizehint parameter passed to readline() calls +MAXLINE = 8192

Exception raised when an error or invalid response is received

@@ -101,6 +103,7 @@ class FTP: debugging = 0 host = '' port = FTP_PORT

@@ -432,7 +437,9 @@ class FTP: conn = self.transfercmd(cmd) fp = conn.makefile('rb') while 1:

@@ -485,7 +492,9 @@ class FTP: self.voidcmd('TYPE A') conn = self.transfercmd(cmd) while 1:

@@ -710,7 +719,9 @@ else: fp = conn.makefile('rb') try: while 1:

@@ -748,7 +759,9 @@ else: conn = self.transfercmd(cmd) try: while 1:

@@ -905,7 +918,9 @@ class Netrc: fp = open(filename, "r") in_macro = 0 while 1:

--- a/Lib/test/test_ftplib.py +++ b/Lib/test/test_ftplib.py @@ -65,6 +65,7 @@ class DummyFTPHandler(asynchat.async_cha self.last_received_data = '' self.next_response = '' self.rest = None

def collect_incoming_data(self, data): @@ -189,7 +190,7 @@ class DummyFTPHandler(asynchat.async_cha offset = int(self.rest) else: offset = 0

@@ -203,6 +204,11 @@ class DummyFTPHandler(asynchat.async_cha self.dtp.push(NLST_DATA) self.dtp.close_when_done()

+ class DummyFTPServer(asyncore.dispatcher, threading.Thread): @@ -558,6 +564,20 @@ class TestFTPClass(TestCase): # IPv4 is in use, just make sure send_epsv has not been used self.assertEqual(self.server.handler.last_received_cmd, 'pasv')

+

+

+ class TestIPv6Environment(TestCase):

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -37,6 +37,10 @@ Core and Builtins Library ------- +- Issue #16038: CVE-2013-1752: ftplib: Limit amount of data read by