1009eb3
From ca207acb4fdea344bb3a775d44aa0d9f59ad31a1 Mon Sep 17 00:00:00 2001
1009eb3
From: Toshio Kuratomi <toshio@fedoraproject.org>
1009eb3
Date: Mon, 15 Jul 2013 10:58:20 -0700
1009eb3
Subject: [PATCH] fix for http://bugs.python.org/issue17980 in code backported
1009eb3
 from the python3 stdlib
1009eb3
1009eb3
---
1009eb3
 pip/backwardcompat/ssl_match_hostname.py | 10 +++++++++-
1009eb3
 1 file changed, 9 insertions(+), 1 deletion(-)
1009eb3
1009eb3
diff --git a/pip/backwardcompat/ssl_match_hostname.py b/pip/backwardcompat/ssl_match_hostname.py
1009eb3
index 5707649..a6fadf4 100644
1009eb3
--- a/pip/backwardcompat/ssl_match_hostname.py
1009eb3
+++ b/pip/backwardcompat/ssl_match_hostname.py
1009eb3
@@ -7,9 +7,17 @@ __version__ = '3.2a3'
1009eb3
 class CertificateError(ValueError):
1009eb3
     pass
1009eb3
 
1009eb3
-def _dnsname_to_pat(dn):
1009eb3
+def _dnsname_to_pat(dn, max_wildcards=1):
1009eb3
     pats = []
1009eb3
     for frag in dn.split(r'.'):
1009eb3
+        if frag.count('*') > max_wildcards:
1009eb3
+            # Issue #17980: avoid denials of service by refusing more
1009eb3
+            # than one wildcard per fragment.  A survery of established
1009eb3
+            # policy among SSL implementations showed it to be a
1009eb3
+            # reasonable choice.
1009eb3
+            raise CertificateError(
1009eb3
+                "too many wildcards in certificate DNS name: " + repr(dn))
1009eb3
+
1009eb3
         if frag == '*':
1009eb3
             # When '*' is a fragment by itself, it matches a non-empty dotless
1009eb3
             # fragment.
1009eb3
-- 
1009eb3
1.7.11.7
1009eb3