summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrian Curtin <brian.curtin@gmail.com>2010-08-06 19:27:32 (GMT)
committerBrian Curtin <brian.curtin@gmail.com>2010-08-06 19:27:32 (GMT)
commitef9efbd69cfe39f8c6034910f551451e5d1e182a (patch)
tree35d402290a43a2962144b403392fa46b674b92f4 /Modules
parente6fc7401a92c7b51a80782d8095819b9909a0322 (diff)
downloadcpython-ef9efbd69cfe39f8c6034910f551451e5d1e182a.zip
cpython-ef9efbd69cfe39f8c6034910f551451e5d1e182a.tar.gz
cpython-ef9efbd69cfe39f8c6034910f551451e5d1e182a.tar.bz2
Fix #9324: Add parameter validation to signal.signal on Windows in order
to prevent crashes.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/signalmodule.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index f4fd964..b5846fa 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -255,8 +255,23 @@ signal_signal(PyObject *self, PyObject *args)
int sig_num;
PyObject *old_handler;
void (*func)(int);
+#ifdef MS_WINDOWS
+ int cur_sig, num_valid_sigs = 6;
+ static int valid_sigs[] = {SIGABRT, SIGFPE, SIGILL, SIGINT,
+ SIGSEGV, SIGTERM};
+ BOOL valid_sig = FALSE;
+#endif
if (!PyArg_ParseTuple(args, "iO:signal", &sig_num, &obj))
return NULL;
+#ifdef MS_WINDOWS
+ /* Validate that sig_num is one of the allowable signals */
+ for (cur_sig = 0; cur_sig < num_valid_sigs; cur_sig++)
+ valid_sig |= (sig_num == valid_sigs[cur_sig]);
+ if (!valid_sig) {
+ PyErr_SetString(PyExc_ValueError, "signal number out of range");
+ return NULL;
+ }
+#endif
#ifdef WITH_THREAD
if (PyThread_get_thread_ident() != main_thread) {
PyErr_SetString(PyExc_ValueError,