[Python-checkins] cpython (merge 3.4 -> default): (Merge 3.4) Issue #21781: Make the ssl module "ssize_t clean" for parsing
victor.stinner
python-checkins at python.org
Tue Jul 1 16:39:34 CEST 2014
http://hg.python.org/cpython/rev/26afcb8a87b9
changeset: 91506:26afcb8a87b9
parent: 91504:2e0a98178c07
parent: 91505:36e884e65e45
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Jul 01 16:39:23 2014 +0200
summary:
(Merge 3.4) Issue #21781: Make the ssl module "ssize_t clean" for parsing
parameters. ssl.RAND_add() now supports strings longer than 2 GB.
files:
Misc/NEWS | 2 ++
Modules/_ssl.c | 11 +++++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -103,6 +103,8 @@
Library
-------
+- Issue #21781: ssl.RAND_add() now supports strings longer than 2 GB.
+
- Issue #21679: Prevent extraneous fstat() calls during open(). Patch by
Bohuslav Kabrda.
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -14,6 +14,8 @@
http://bugs.python.org/issue8108#msg102867 ?
*/
+#define PY_SSIZE_T_CLEAN
+
#include "Python.h"
#ifdef WITH_THREAD
@@ -3233,12 +3235,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;
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list