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

Skip to content

Commit 2e57b4e

Browse files
committed
Issue #21781: Make the ssl module "ssize_t clean" for parsing parameters.
ssl.RAND_add() now supports strings longer than 2 GB.
1 parent 1690ed3 commit 2e57b4e

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
@@ -27,6 +27,8 @@ Core and Builtins
2727
Library
2828
-------
2929

30+
- Issue #21781: ssl.RAND_add() now supports strings longer than 2 GB.
31+
3032
- Issue #11453: asyncore: emit a ResourceWarning when an unclosed file_wrapper
3133
object is destroyed. The destructor now closes the file if needed. The
3234
close() method can now be called twice: the second call does nothing.

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
@@ -3235,12 +3237,17 @@ static PyObject *
32353237
PySSL_RAND_add(PyObject *self, PyObject *args)
32363238
{
32373239
char *buf;
3238-
int len;
3240+
Py_ssize_t len, written;
32393241
double entropy;
32403242

32413243
if (!PyArg_ParseTuple(args, "s#d:RAND_add", &buf, &len, &entropy))
32423244
return NULL;
3243-
RAND_add(buf, len, entropy);
3245+
do {
3246+
written = Py_MIN(len, INT_MAX);
3247+
RAND_add(buf, (int)written, entropy);
3248+
buf += written;
3249+
len -= written;
3250+
} while (len);
32443251
Py_INCREF(Py_None);
32453252
return Py_None;
32463253
}

0 commit comments

Comments
 (0)