summaryrefslogtreecommitdiff
path: root/Lib/smtplib.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2014-02-10 22:04:20 +0100
committerGeorg Brandl <georg@python.org>2014-02-10 22:04:20 +0100
commit8f9c20b8ff6d00a32ff3f4018969e80e237884dc (patch)
tree9e5670bfca7ba58b303de5bd470f5088afe419f2 /Lib/smtplib.py
parent72e7761301febe026536e7a2a444269698dcf156 (diff)
parenta37fcb28e6bcfd7705f219c12834b4d23a9ed499 (diff)
downloadcpython-git-8f9c20b8ff6d00a32ff3f4018969e80e237884dc.tar.gz
merge with 3.3.4 releasing repo
Diffstat (limited to 'Lib/smtplib.py')
-rwxr-xr-xLib/smtplib.py5
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.