Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7f08406

Browse files
committed
(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.
2 parents 6a75bb0 + 2e57b4e commit 7f08406

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ Core and Builtins
103103
Library
104104
-------
105105

106+
- Issue #21781: ssl.RAND_add() now supports strings longer than 2 GB.
107+
106108
- Issue #21679: Prevent extraneous fstat() calls during open(). Patch by
107109
Bohuslav Kabrda.
108110

Modules/_ssl.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
http://bugs.python.org/issue8108#msg102867 ?
1515
*/
1616

17+
#define PY_SSIZE_T_CLEAN
18+
1719
#include "Python.h"
1820

1921
#ifdef WITH_THREAD
@@ -3233,12 +3235,17 @@ static PyObject *
32333235
PySSL_RAND_add(PyObject *self, PyObject *args)
32343236
{
32353237
char *buf;
3236-
int len;
3238+
Py_ssize_t len, written;
32373239
double entropy;
32383240

32393241
if (!PyArg_ParseTuple(args, "s#d:RAND_add", &buf, &len, &entropy))
32403242
return NULL;
3241-
RAND_add(buf, len, entropy);
3243+
do {
3244+
written = Py_MIN(len, INT_MAX);
3245+
RAND_add(buf, (int)written, entropy);
3246+
buf += written;
3247+
len -= written;
3248+
} while (len);
32423249
Py_INCREF(Py_None);
32433250
return Py_None;
32443251
}

0 commit comments

Comments
 (0)