summaryrefslogtreecommitdiffstats
path: root/Modules/_ssl.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-05-16 21:23:48 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-05-16 21:23:48 (GMT)
commit3800e1e961aec798d4d057e82c79740dcea5d2ef (patch)
tree107e50a40ac6a1c8a1be0213f378ce61ac15d1f3 /Modules/_ssl.c
parent27ba6388ed932af9e2c91e21d1ed3f260437e377 (diff)
downloadcpython-3800e1e961aec798d4d057e82c79740dcea5d2ef.zip
cpython-3800e1e961aec798d4d057e82c79740dcea5d2ef.tar.gz
cpython-3800e1e961aec798d4d057e82c79740dcea5d2ef.tar.bz2
Issue #8477: _ssl._test_decode_cert() supports str with surrogates and bytes
for the filename
Diffstat (limited to 'Modules/_ssl.c')
-rw-r--r--Modules/_ssl.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 39fec7b..d01fafd 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -811,13 +811,13 @@ static PyObject *
PySSL_test_decode_certificate (PyObject *mod, PyObject *args) {
PyObject *retval = NULL;
- char *filename = NULL;
+ PyObject *filename;
X509 *x=NULL;
BIO *cert;
int verbose = 1;
- if (!PyArg_ParseTuple(args, "s|i:test_decode_certificate",
- &filename, &verbose))
+ if (!PyArg_ParseTuple(args, "O&|i:test_decode_certificate",
+ PyUnicode_FSConverter, &filename, &verbose))
return NULL;
if ((cert=BIO_new(BIO_s_file())) == NULL) {
@@ -826,7 +826,7 @@ PySSL_test_decode_certificate (PyObject *mod, PyObject *args) {
goto fail0;
}
- if (BIO_read_filename(cert,filename) <= 0) {
+ if (BIO_read_filename(cert, PyBytes_AsString(filename)) <= 0) {
PyErr_SetString(PySSLErrorObject,
"Can't open file");
goto fail0;
@@ -842,7 +842,7 @@ PySSL_test_decode_certificate (PyObject *mod, PyObject *args) {
retval = _decode_certificate(x, verbose);
fail0:
-
+ Py_DECREF(filename);
if (cert != NULL) BIO_free(cert);
return retval;
}