]> granicus.if.org Git - python/commitdiff
Issue #10989: Fix a crash on SSLContext.load_verify_locations(None, True).
authorVictor Stinner <victor.stinner@haypocalc.com>
Sat, 29 Jan 2011 11:31:20 +0000 (11:31 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sat, 29 Jan 2011 11:31:20 +0000 (11:31 +0000)
Patch reviewed by Antoine Pitrou, okayed by Georg Brandl.

Lib/test/test_ssl.py
Misc/NEWS
Modules/_ssl.c

index 0e4759554aa3135f2ba0603f8b91248ceab76cf7..4ea1a63e4959c548393a7a86fde13c7bc1eea031 100644 (file)
@@ -394,6 +394,9 @@ class ContextTests(unittest.TestCase):
         ctx.load_verify_locations(CERTFILE, CAPATH)
         ctx.load_verify_locations(CERTFILE, capath=BYTES_CAPATH)
 
+        # Issue #10989: crash if the second argument type is invalid
+        self.assertRaises(TypeError, ctx.load_verify_locations, None, True)
+
     @skip_if_broken_ubuntu_ssl
     def test_session_stats(self):
         for proto in PROTOCOLS:
index b05b93caa8643a80b280f2e5600670b9a66355ef..51f5ac151b792d3e86d89d66501ccb41a5eee673 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -16,6 +16,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #10989: Fix a crash on SSLContext.load_verify_locations(None, True).
+
 - Issue #11020: Command-line pyclbr was broken because of missing 2-to-3
   conversion.
 
index 1e4b38a9cd88ac2a12e997272df86b65308bd08b..141b1ae88cef0fcf5bd89e14bfeb7b81607924b8 100644 (file)
@@ -1683,7 +1683,7 @@ load_verify_locations(PySSLContext *self, PyObject *args, PyObject *kwds)
         return NULL;
     }
     if (capath && !PyUnicode_FSConverter(capath, &capath_bytes)) {
-        Py_DECREF(cafile_bytes);
+        Py_XDECREF(cafile_bytes);
         PyErr_SetString(PyExc_TypeError,
                         "capath should be a valid filesystem path");
         return NULL;