#16042: CVE-2013-1752: smtplib fix for unlimited readline() from socket

This commit is contained in:
Georg Brandl 2014-01-25 09:02:18 +01:00
parent f580d5b6f7
commit c11435399e
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