104735a
From 761db274ca898f8a92348ed5979d3d3c1b0d634a Mon Sep 17 00:00:00 2001
104735a
From: Tomas Orsava <torsava@redhat.com>
104735a
Date: Fri, 17 Jun 2016 16:08:11 +0200
104735a
Subject: [PATCH] Raise an error when STARTTLS fails
104735a
104735a
CVE-2016-0772 python: smtplib StartTLS stripping attack
104735a
rhbz#1303647: https://bugzilla.redhat.com/show_bug.cgi?id=1303647
104735a
rhbz#1346345: https://bugzilla.redhat.com/show_bug.cgi?id=1346345
104735a
104735a
Based on an upstream change by Benjamin Peterson <benjamin@python.org>
104735a
- in changeset 101887:d590114c2394 3.4
104735a
- https://hg.python.org/cpython/rev/d590114c2394
104735a
---
104735a
 Lib/smtplib.py | 5 +++++
104735a
 1 file changed, 5 insertions(+)
104735a
104735a
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
104735a
index 4756973..dfbf5f9 100755
104735a
--- a/Lib/smtplib.py
104735a
+++ b/Lib/smtplib.py
104735a
@@ -773,6 +773,11 @@ class SMTP:
104735a
             self.ehlo_resp = None
104735a
             self.esmtp_features = {}
104735a
             self.does_esmtp = 0
104735a
+        else:
104735a
+            # RFC 3207:
104735a
+            # 501 Syntax error (no parameters allowed)
104735a
+            # 454 TLS not available due to temporary reason
104735a
+            raise SMTPResponseException(resp, reply)
104735a
         return (resp, reply)
104735a
 
104735a
     def sendmail(self, from_addr, to_addrs, msg, mail_options=[],
104735a
-- 
104735a
2.5.5
104735a