Commit 80f75e68 authored by Victor Stinner's avatar Victor Stinner

Issue #10989: Fix a crash on SSLContext.load_verify_locations(None, True).

Patch reviewed by Antoine Pitrou, okayed by Georg Brandl.
parent a1eac721
...@@ -394,6 +394,9 @@ class ContextTests(unittest.TestCase): ...@@ -394,6 +394,9 @@ class ContextTests(unittest.TestCase):
ctx.load_verify_locations(CERTFILE, CAPATH) ctx.load_verify_locations(CERTFILE, CAPATH)
ctx.load_verify_locations(CERTFILE, capath=BYTES_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 @skip_if_broken_ubuntu_ssl
def test_session_stats(self): def test_session_stats(self):
for proto in PROTOCOLS: for proto in PROTOCOLS:
......
...@@ -16,6 +16,8 @@ Core and Builtins ...@@ -16,6 +16,8 @@ Core and Builtins
Library 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 - Issue #11020: Command-line pyclbr was broken because of missing 2-to-3
conversion. conversion.
......
...@@ -1683,7 +1683,7 @@ load_verify_locations(PySSLContext *self, PyObject *args, PyObject *kwds) ...@@ -1683,7 +1683,7 @@ load_verify_locations(PySSLContext *self, PyObject *args, PyObject *kwds)
return NULL; return NULL;
} }
if (capath && !PyUnicode_FSConverter(capath, &capath_bytes)) { if (capath && !PyUnicode_FSConverter(capath, &capath_bytes)) {
Py_DECREF(cafile_bytes); Py_XDECREF(cafile_bytes);
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"capath should be a valid filesystem path"); "capath should be a valid filesystem path");
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment