summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-07-01 14:37:17 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-07-01 14:37:17 (GMT)
commit2e57b4e488ddeabe61fe3ca579df908a921bac06 (patch)
tree143bb09c190a6621d24daac991687ff7490ba3be /Modules
parent1690ed397aadf4cc2057c43d960dbe2ba9e556d0 (diff)
downloadcpython-2e57b4e488ddeabe61fe3ca579df908a921bac06.zip
cpython-2e57b4e488ddeabe61fe3ca579df908a921bac06.tar.gz
cpython-2e57b4e488ddeabe61fe3ca579df908a921bac06.tar.bz2
Issue #21781: Make the ssl module "ssize_t clean" for parsing parameters.
ssl.RAND_add() now supports strings longer than 2 GB.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ssl.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 5031476..12ffe52 100644
--- 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
@@ -3235,12 +3237,17 @@ static PyObject *
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;
}