cpython: 923aac88a3cc (original) (raw)

Mercurial > cpython

changeset 93747:923aac88a3cc 2.7

smtplib: limit amount read from the network (closes #16042) [#16042]

Benjamin Peterson benjamin@python.org
date Fri, 05 Dec 2014 20:05:18 -0500
parents 339f877cca11
children d50096708b2d
files Lib/smtplib.py Lib/test/test_smtplib.py Misc/NEWS
diffstat 3 files changed, 41 insertions(+), 3 deletions(-)[+] [-] Lib/smtplib.py 11 Lib/test/test_smtplib.py 30 Misc/NEWS 3

line wrap: on

line diff

--- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -57,6 +57,7 @@ from sys import stderr SMTP_PORT = 25 SMTP_SSL_PORT = 465 CRLF = "\r\n" +_MAXLINE = 8192 # more than 8 times larger than RFC 821, 4.5.3 OLDSTYLE_AUTH = re.compile(r"auth=(.*)", re.I) @@ -179,10 +180,14 @@ else: def init(self, sslobj): self.sslobj = sslobj

@@ -353,7 +358,7 @@ class SMTP: self.file = self.sock.makefile('rb') while 1: try:

@@ -363,6 +368,8 @@ class SMTP: raise SMTPServerDisconnected("Connection unexpectedly closed") if self.debuglevel > 0: print>>stderr, 'reply:', repr(line)

--- a/Lib/test/test_smtplib.py +++ b/Lib/test/test_smtplib.py @@ -292,6 +292,33 @@ class BadHELOServerTests(unittest.TestCa HOST, self.port, 'localhost', 3) +@unittest.skipUnless(threading, 'Threading required for this test.') +class TooLongLineTests(unittest.TestCase):

+

+

+

+

+ + sim_users = {'Mr.A@somewhere.com':'John A', 'Ms.B@somewhere.com':'Sally B', 'Mrs.C@somewhereesle.com':'Ruth C', @@ -526,7 +553,8 @@ class SMTPSimTests(unittest.TestCase): def test_main(verbose=None): test_support.run_unittest(GeneralTests, DebuggingServerTests, NonConnectingTests,

if name == 'main': test_main()

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ What's New in Python 2.7.9? Library ------- +- Issue #16042: CVE-2013-1752: smtplib: Limit amount of data read by limiting