diff options
author | Nathaniel J. Smith <njs@pobox.com> | 2017-06-09 09:35:16 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2017-06-09 09:35:16 (GMT) |
commit | 59fdf0f3ba0469f5ee45eee59cc166411fbe0b75 (patch) | |
tree | bb2e38493907da1c4786aa6b048f316ca7a991f2 | |
parent | ef8320cf6f09b659c63bfb188bf45dbcae556762 (diff) | |
download | cpython-59fdf0f3ba0469f5ee45eee59cc166411fbe0b75.zip cpython-59fdf0f3ba0469f5ee45eee59cc166411fbe0b75.tar.gz cpython-59fdf0f3ba0469f5ee45eee59cc166411fbe0b75.tar.bz2 |
Add a test for bad IDNA in ssl server_hostname (#1997)
See discussion:
https://github.com/python/cpython/pull/1992#issuecomment-307024778
-rw-r--r-- | Lib/test/test_ssl.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 8dcd3b6..fdaf1c5 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -1393,6 +1393,16 @@ class SSLErrorTests(unittest.TestCase): # For compatibility self.assertEqual(cm.exception.errno, ssl.SSL_ERROR_WANT_READ) + def test_bad_idna_in_server_hostname(self): + # Note: this test is testing some code that probably shouldn't exist + # in the first place, so if it starts failing at some point because + # you made the ssl module stop doing IDNA decoding then please feel + # free to remove it. The test was mainly added because this case used + # to cause memory corruption (see bpo-30594). + ctx = ssl.create_default_context() + with self.assertRaises(UnicodeError): + ctx.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(), + server_hostname="xn--.com") class MemoryBIOTests(unittest.TestCase): |