diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-07-24 06:02:53 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-07-24 06:02:53 (GMT) |
commit | 178f0b6ddcae040c235188b49c1f6defc76588ca (patch) | |
tree | 44fdcf3d5091a66897eaba20dad10610960785b9 /Modules | |
parent | f79dfe3f250bab3375120e4f30643abac08b652d (diff) | |
download | cpython-178f0b6ddcae040c235188b49c1f6defc76588ca.zip cpython-178f0b6ddcae040c235188b49c1f6defc76588ca.tar.gz cpython-178f0b6ddcae040c235188b49c1f6defc76588ca.tar.bz2 |
Issue #24620: Random.setstate() now validates the value of state last element.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_randommodule.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c index 4377ee0..416e266 100644 --- a/Modules/_randommodule.c +++ b/Modules/_randommodule.c @@ -340,6 +340,10 @@ random_setstate(RandomObject *self, PyObject *state) index = PyLong_AsLong(PyTuple_GET_ITEM(state, i)); if (index == -1 && PyErr_Occurred()) return NULL; + if (index < 0 || index > N) { + PyErr_SetString(PyExc_ValueError, "invalid state"); + return NULL; + } self->index = (int)index; Py_INCREF(Py_None); |