summaryrefslogtreecommitdiffstats
path: root/Modules/_randommodule.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-07-24 06:05:59 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-07-24 06:05:59 (GMT)
commitc19bb3279cbb42c84a24255db48ee2d385bb8167 (patch)
tree72fa9802d7f4c2b0078fbdff5c078e06af3b06e0 /Modules/_randommodule.c
parent5b718d7f4fc3ad28ffb774aa96324a81f5f3e742 (diff)
parent178f0b6ddcae040c235188b49c1f6defc76588ca (diff)
downloadcpython-c19bb3279cbb42c84a24255db48ee2d385bb8167.zip
cpython-c19bb3279cbb42c84a24255db48ee2d385bb8167.tar.gz
cpython-c19bb3279cbb42c84a24255db48ee2d385bb8167.tar.bz2
Issue #24620: Random.setstate() now validates the value of state last element.
Diffstat (limited to 'Modules/_randommodule.c')
-rw-r--r--Modules/_randommodule.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c
index df149c5..95ad4a4 100644
--- a/Modules/_randommodule.c
+++ b/Modules/_randommodule.c
@@ -335,6 +335,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);