diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-16 21:36:37 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-16 21:36:37 (GMT) |
commit | f9faaad80107338b2248b0486bc7069b06f19677 (patch) | |
tree | 6f2b5793e9310bcd6efd6166083b12cb2e22f0a7 /Modules/_ssl.c | |
parent | 3800e1e961aec798d4d057e82c79740dcea5d2ef (diff) | |
download | cpython-f9faaad80107338b2248b0486bc7069b06f19677.zip cpython-f9faaad80107338b2248b0486bc7069b06f19677.tar.gz cpython-f9faaad80107338b2248b0486bc7069b06f19677.tar.bz2 |
Issue #8477: ssl.RAND_egd() supports str with surrogates and bytes for the path
Diffstat (limited to 'Modules/_ssl.c')
-rw-r--r-- | Modules/_ssl.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c index d01fafd..4aa1e2d 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -1730,15 +1730,17 @@ It is necessary to seed the PRNG with RAND_add() on some platforms before\n\ using the ssl() function."); static PyObject * -PySSL_RAND_egd(PyObject *self, PyObject *arg) +PySSL_RAND_egd(PyObject *self, PyObject *args) { + PyObject *path; int bytes; - if (!PyUnicode_Check(arg)) - return PyErr_Format(PyExc_TypeError, - "RAND_egd() expected string, found %s", - Py_TYPE(arg)->tp_name); - bytes = RAND_egd(_PyUnicode_AsString(arg)); + if (!PyArg_ParseTuple(args, "O&|i:RAND_egd", + PyUnicode_FSConverter, &path)) + return NULL; + + bytes = RAND_egd(PyBytes_AsString(path)); + Py_DECREF(path); if (bytes == -1) { PyErr_SetString(PySSLErrorObject, "EGD connection failed or EGD did not return " @@ -1767,7 +1769,7 @@ static PyMethodDef PySSL_methods[] = { #ifdef HAVE_OPENSSL_RAND {"RAND_add", PySSL_RAND_add, METH_VARARGS, PySSL_RAND_add_doc}, - {"RAND_egd", PySSL_RAND_egd, METH_O, + {"RAND_egd", PySSL_RAND_egd, METH_VARARGS, PySSL_RAND_egd_doc}, {"RAND_status", (PyCFunction)PySSL_RAND_status, METH_NOARGS, PySSL_RAND_status_doc}, |