summaryrefslogtreecommitdiffstats
path: root/Lib/smtplib.py
diff options
context:
space:
mode:
authorLarry Hastings <larry@hastings.org>2014-02-11 08:15:46 (GMT)
committerLarry Hastings <larry@hastings.org>2014-02-11 08:15:46 (GMT)
commit3f99504c08ebca685271c32289f8907bc456e1fc (patch)
treedeb0b2d3284cec1323ad0da34f96107ea3f64576 /Lib/smtplib.py
parent4cce8f2f40cc15235f44b3a47fec0444ed75e9fe (diff)
parent06847d9c8c30715c077e083de1c511e399af75f1 (diff)
downloadcpython-3f99504c08ebca685271c32289f8907bc456e1fc.zip
cpython-3f99504c08ebca685271c32289f8907bc456e1fc.tar.gz
cpython-3f99504c08ebca685271c32289f8907bc456e1fc.tar.bz2
Merge Python 3.4.0rc1 release branch.
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 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.