diff options
author | Georg Brandl <georg@python.org> | 2014-02-10 22:04:20 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-02-10 22:04:20 +0100 |
commit | 8f9c20b8ff6d00a32ff3f4018969e80e237884dc (patch) | |
tree | 9e5670bfca7ba58b303de5bd470f5088afe419f2 /Lib/smtplib.py | |
parent | 72e7761301febe026536e7a2a444269698dcf156 (diff) | |
parent | a37fcb28e6bcfd7705f219c12834b4d23a9ed499 (diff) | |
download | cpython-git-8f9c20b8ff6d00a32ff3f4018969e80e237884dc.tar.gz |
merge with 3.3.4 releasing repo
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 072b973e0e..57f181b986 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) @@ -364,7 +365,7 @@ class SMTP: self.file = self.sock.makefile('rb') while 1: try: - line = self.file.readline() + line = self.file.readline(_MAXLINE + 1) except socket.error as e: self.close() raise SMTPServerDisconnected("Connection unexpectedly closed: " @@ -374,6 +375,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. |