changeset: 91505:36e884e65e45 branch: 3.4 parent: 91503:9b9ea48a76a5 user: Victor Stinner date: Tue Jul 01 16:37:17 2014 +0200 files: Misc/NEWS Modules/_ssl.c description: Issue #21781: Make the ssl module "ssize_t clean" for parsing parameters. ssl.RAND_add() now supports strings longer than 2 GB. diff -r 9b9ea48a76a5 -r 36e884e65e45 Misc/NEWS --- a/Misc/NEWS Tue Jul 01 12:38:51 2014 +0200 +++ b/Misc/NEWS Tue Jul 01 16:37:17 2014 +0200 @@ -27,6 +27,8 @@ Library ------- +- Issue #21781: ssl.RAND_add() now supports strings longer than 2 GB. + - Issue #11453: asyncore: emit a ResourceWarning when an unclosed file_wrapper object is destroyed. The destructor now closes the file if needed. The close() method can now be called twice: the second call does nothing. diff -r 9b9ea48a76a5 -r 36e884e65e45 Modules/_ssl.c --- a/Modules/_ssl.c Tue Jul 01 12:38:51 2014 +0200 +++ b/Modules/_ssl.c Tue Jul 01 16:37:17 2014 +0200 @@ -14,6 +14,8 @@ http://bugs.python.org/issue8108#msg102867 ? */ +#define PY_SSIZE_T_CLEAN + #include "Python.h" #ifdef WITH_THREAD @@ -3235,12 +3237,17 @@ PySSL_RAND_add(PyObject *self, PyObject *args) { char *buf; - int len; + Py_ssize_t len, written; double entropy; if (!PyArg_ParseTuple(args, "s#d:RAND_add", &buf, &len, &entropy)) return NULL; - RAND_add(buf, len, entropy); + do { + written = Py_MIN(len, INT_MAX); + RAND_add(buf, (int)written, entropy); + buf += written; + len -= written; + } while (len); Py_INCREF(Py_None); return Py_None; }