summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2016-08-13 18:21:16 -0700
committerBenjamin Peterson <benjamin@python.org>2016-08-13 18:21:16 -0700
commitf17a8e9acd6f4b9056f412595ffdbaf8e4c5b7ec (patch)
treefa22d3d0a142786587fdfd0ccd5d871b3809f333
parent9745ee0b444c92a23a1b8851f789044baa64dba5 (diff)
parent40a77c33819606b40ca04f680a06fcf31e2151a6 (diff)
downloadcpython-git-f17a8e9acd6f4b9056f412595ffdbaf8e4c5b7ec.tar.gz
merge 3.4
-rw-r--r--Lib/test/test_curses.py3
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/_cursesmodule.c8
3 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py
index 897d738f57..6bbb3fc97c 100644
--- a/Lib/test/test_curses.py
+++ b/Lib/test/test_curses.py
@@ -188,6 +188,9 @@ class TestCurses(unittest.TestCase):
if hasattr(curses, 'enclose'):
stdscr.enclose()
+ self.assertRaises(ValueError, stdscr.getstr, -400)
+ self.assertRaises(ValueError, stdscr.getstr, 2, 3, -400)
+
def test_module_funcs(self):
"Test module-level functions"
diff --git a/Misc/NEWS b/Misc/NEWS
index ed580d1c00..60d6c5f41b 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -37,6 +37,9 @@ Library
- Issue #26750: unittest.mock.create_autospec() now works properly for
subclasses of property() and other data descriptors.
+- In the curses module, raise an error if window.getstr() is passed a negative
+ value.
+
- Issue #27758: Fix possible integer overflow in the _csv module for large record
lengths.
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index d64bdc74e9..06aa46c313 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -1221,6 +1221,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
@@ -1239,6 +1243,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 :