Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
40a77c33
Commit
40a77c33
authored
Aug 13, 2016
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
do not allow reading negative values with getstr()
parent
59b6abd3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
0 deletions
+14
-0
Lib/test/test_curses.py
Lib/test/test_curses.py
+3
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_cursesmodule.c
Modules/_cursesmodule.c
+8
-0
No files found.
Lib/test/test_curses.py
View file @
40a77c33
...
...
@@ -163,6 +163,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"
...
...
Misc/NEWS
View file @
40a77c33
...
...
@@ -13,6 +13,9 @@ Core and Builtins
Library
-------
- 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.
...
...
Modules/_cursesmodule.c
View file @
40a77c33
...
...
@@ -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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment