Issue #16042: CVE-2013-1752: smtplib: Limit amount of data read by

limiting the call to readline().  Original patch by Christian Heimes.
This commit is contained in:
Georg Brandl 2014-09-30 14:18:02 +02:00
parent 70088f14ad
commit 210ee47e33
4 changed files with 43 additions and 4 deletions

View file

@ -21,8 +21,13 @@ class MockFile:
"""
def __init__(self, lines):
self.lines = lines
def readline(self):
return self.lines.pop(0) + b'\r\n'
def readline(self, limit=-1):
result = self.lines.pop(0) + b'\r\n'
if limit >= 0:
# Re-insert the line, removing the \r\n we added.
self.lines.insert(0, result[limit:-2])
result = result[:limit]
return result
def close(self):
pass