]> granicus.if.org Git - python/commitdiff
Issue #8477: ssl.RAND_egd() supports str with surrogates and bytes for the path
authorVictor Stinner <victor.stinner@haypocalc.com>
Sun, 16 May 2010 21:36:37 +0000 (21:36 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sun, 16 May 2010 21:36:37 +0000 (21:36 +0000)
Misc/NEWS
Modules/_ssl.c

index c26de6177f7908efe0e99e1160ec110c1444991e..f801e3e39c647e3713520fb421ca1afc816319e3 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -363,8 +363,8 @@ C-API
 Library
 -------
 
-- Issue #8477: _ssl._test_decode_cert() supports str with surrogates and bytes
-  for the filename
+- Issue #8477: ssl.RAND_egd() and ssl._test_decode_cert() support str with
+  surrogates and bytes for the filename
 
 - Issue #8550: Add first class ``SSLContext`` objects to the ssl module.
 
index d01fafd5c48557200aa632056fb896dceb9937f2..4aa1e2d6ec108e56b75ca567023c846141c1e2d2 100644 (file)
@@ -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},