mirror of
https://github.com/python/cpython.git
synced 2025-08-08 02:48:55 +00:00
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:
parent
70088f14ad
commit
210ee47e33
4 changed files with 43 additions and 4 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue