summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2017-11-01 19:23:46 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-11-01 19:23:46 (GMT)
commitaad7ac10af6ed40fc21b842e04be0b04b2915d4a (patch)
tree42bc2d36428ae02c54893876c8c383d57f156f83 /Modules
parent1f81ea85e8e20347ec396001e5b869d36fe38398 (diff)
downloadcpython-aad7ac10af6ed40fc21b842e04be0b04b2915d4a.zip
cpython-aad7ac10af6ed40fc21b842e04be0b04b2915d4a.tar.gz
cpython-aad7ac10af6ed40fc21b842e04be0b04b2915d4a.tar.bz2
bpo-27666: Fixed stack corruption in curses.box() and curses.ungetmouse(). (GH-4220) (#4221)
(cherry picked from commit 4f469c096628af730b17798d0ebfd8925bfde836)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_cursesmodule.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index 0e4cd53..9a691db 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -912,12 +912,19 @@ PyCursesWindow_Border(PyCursesWindowObject *self, PyObject *args)
static PyObject *
PyCursesWindow_Box(PyCursesWindowObject *self, PyObject *args)
{
+ PyObject *temp1, *temp2;
chtype ch1=0,ch2=0;
switch(PyTuple_Size(args)){
case 0: break;
default:
- if (!PyArg_ParseTuple(args,"ll;vertint,horint", &ch1, &ch2))
+ if (!PyArg_ParseTuple(args,"OO;verch,horch", &temp1, &temp2))
return NULL;
+ if (!PyCurses_ConvertToChtype(self, temp1, &ch1)) {
+ return NULL;
+ }
+ if (!PyCurses_ConvertToChtype(self, temp2, &ch2)) {
+ return NULL;
+ }
}
box(self->win,ch1,ch2);
Py_INCREF(Py_None);
@@ -2285,24 +2292,30 @@ PyCurses_GetMouse(PyObject *self)
PyErr_SetString(PyCursesError, "getmouse() returned ERR");
return NULL;
}
- return Py_BuildValue("(hiiil)",
+ return Py_BuildValue("(hiiik)",
(short)event.id,
- event.x, event.y, event.z,
- (long) event.bstate);
+ (int)event.x, (int)event.y, (int)event.z,
+ (unsigned long) event.bstate);
}
static PyObject *
PyCurses_UngetMouse(PyObject *self, PyObject *args)
{
MEVENT event;
+ short id;
+ int x, y, z;
+ unsigned long bstate;
PyCursesInitialised;
- if (!PyArg_ParseTuple(args, "hiiil",
- &event.id,
- &event.x, &event.y, &event.z,
- (int *) &event.bstate))
+ if (!PyArg_ParseTuple(args, "hiiik",
+ &id, &x, &y, &z, &bstate))
return NULL;
+ event.id = id;
+ event.x = x;
+ event.y = y;
+ event.z = z;
+ event.bstate = bstate;
return PyCursesCheckERR(ungetmouse(&event), "ungetmouse");
}
#endif
@@ -2701,14 +2714,15 @@ PyCurses_MouseInterval(PyObject *self, PyObject *args)
static PyObject *
PyCurses_MouseMask(PyObject *self, PyObject *args)
{
- int newmask;
+ unsigned long newmask;
mmask_t oldmask, availmask;
PyCursesInitialised;
- if (!PyArg_ParseTuple(args,"i;mousemask",&newmask))
+ if (!PyArg_ParseTuple(args,"k;mousemask",&newmask))
return NULL;
- availmask = mousemask(newmask, &oldmask);
- return Py_BuildValue("(ll)", (long)availmask, (long)oldmask);
+ availmask = mousemask((mmask_t)newmask, &oldmask);
+ return Py_BuildValue("(kk)",
+ (unsigned long)availmask, (unsigned long)oldmask);
}
#endif