diff options
author | Benjamin Peterson <benjamin@python.org> | 2016-08-14 01:15:28 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2016-08-14 01:15:28 (GMT) |
commit | 40a77c33819606b40ca04f680a06fcf31e2151a6 (patch) | |
tree | b8cb6de1e26e2a02bfdb60a79622e548384a4591 /Modules | |
parent | 59b6abd38c04472a256b1b04e8709defb29e44ef (diff) | |
download | cpython-40a77c33819606b40ca04f680a06fcf31e2151a6.zip cpython-40a77c33819606b40ca04f680a06fcf31e2151a6.tar.gz cpython-40a77c33819606b40ca04f680a06fcf31e2151a6.tar.bz2 |
do not allow reading negative values with getstr()
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_cursesmodule.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index 5ffce2f..a8735f2 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -1284,6 +1284,10 @@ PyCursesWindow_GetStr(PyCursesWindowObject *self, PyObject *args) case 1: if (!PyArg_ParseTuple(args,"i;n", &n)) return NULL; + if (n < 0) { + PyErr_SetString(PyExc_ValueError, "'n' must be nonnegative"); + return NULL; + } Py_BEGIN_ALLOW_THREADS rtn2 = wgetnstr(self->win, rtn, Py_MIN(n, 1023)); Py_END_ALLOW_THREADS @@ -1302,6 +1306,10 @@ PyCursesWindow_GetStr(PyCursesWindowObject *self, PyObject *args) case 3: if (!PyArg_ParseTuple(args,"iii;y,x,n", &y, &x, &n)) return NULL; + if (n < 0) { + PyErr_SetString(PyExc_ValueError, "'n' must be nonnegative"); + return NULL; + } #ifdef STRICT_SYSV_CURSES Py_BEGIN_ALLOW_THREADS rtn2 = wmove(self->win,y,x)==ERR ? ERR : |