diff options
author | Georg Brandl <georg@python.org> | 2014-02-10 21:11:21 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-02-10 21:11:21 (GMT) |
commit | b38b5c43c710da8fd6034d1dab631c5b020652bf (patch) | |
tree | 567e29cd2f5fe5bfb48bce00109321cd29ae1bff /Lib/smtplib.py | |
parent | 6093a125ee900738a1840afb6980ec426cacad68 (diff) | |
download | cpython-b38b5c43c710da8fd6034d1dab631c5b020652bf.zip cpython-b38b5c43c710da8fd6034d1dab631c5b020652bf.tar.gz cpython-b38b5c43c710da8fd6034d1dab631c5b020652bf.tar.bz2 |
merge with 3.3
Diffstat (limited to 'Lib/smtplib.py')
-rwxr-xr-x | Lib/smtplib.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/smtplib.py b/Lib/smtplib.py index 796b866..66b5879 100755 --- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -62,6 +62,7 @@ SMTP_PORT = 25 SMTP_SSL_PORT = 465 CRLF = "\r\n" bCRLF = b"\r\n" +_MAXLINE = 8192 # more than 8 times larger than RFC 821, 4.5.3 OLDSTYLE_AUTH = re.compile(r"auth=(.*)", re.I) @@ -365,7 +366,7 @@ class SMTP: self.file = self.sock.makefile('rb') while 1: try: - line = self.file.readline() + line = self.file.readline(_MAXLINE + 1) except OSError as e: self.close() raise SMTPServerDisconnected("Connection unexpectedly closed: " @@ -375,6 +376,8 @@ class SMTP: raise SMTPServerDisconnected("Connection unexpectedly closed") if self.debuglevel > 0: print('reply:', repr(line), file=stderr) + if len(line) > _MAXLINE: + raise SMTPResponseException(500, "Line too long.") resp.append(line[4:].strip(b' \t\r\n')) code = line[:3] # Check that the error code is syntactically correct. |