(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.
This commit is contained in:
commit
7f084064e8
|
@ -103,6 +103,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #21781: ssl.RAND_add() now supports strings longer than 2 GB.
|
||||||
|
|
||||||
- Issue #21679: Prevent extraneous fstat() calls during open(). Patch by
|
- Issue #21679: Prevent extraneous fstat() calls during open(). Patch by
|
||||||
Bohuslav Kabrda.
|
Bohuslav Kabrda.
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
http://bugs.python.org/issue8108#msg102867 ?
|
http://bugs.python.org/issue8108#msg102867 ?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define PY_SSIZE_T_CLEAN
|
||||||
|
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
|
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
|
@ -3233,12 +3235,17 @@ static PyObject *
|
||||||
PySSL_RAND_add(PyObject *self, PyObject *args)
|
PySSL_RAND_add(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
int len;
|
Py_ssize_t len, written;
|
||||||
double entropy;
|
double entropy;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "s#d:RAND_add", &buf, &len, &entropy))
|
if (!PyArg_ParseTuple(args, "s#d:RAND_add", &buf, &len, &entropy))
|
||||||
return NULL;
|
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);
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue