diff options
author | Brian Curtin <brian.curtin@gmail.com> | 2010-08-06 19:34:52 (GMT) |
---|---|---|
committer | Brian Curtin <brian.curtin@gmail.com> | 2010-08-06 19:34:52 (GMT) |
commit | 3f004b1cc0190b9e2b0f0e5c26847b5594ca661d (patch) | |
tree | 573f106acb895a0e21649fde273ee7631d791a74 /Modules/signalmodule.c | |
parent | 40b3744efa2572ce429771d6971f7972a12c2405 (diff) | |
download | cpython-3f004b1cc0190b9e2b0f0e5c26847b5594ca661d.zip cpython-3f004b1cc0190b9e2b0f0e5c26847b5594ca661d.tar.gz cpython-3f004b1cc0190b9e2b0f0e5c26847b5594ca661d.tar.bz2 |
Merged revisions 83763 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r83763 | brian.curtin | 2010-08-06 14:27:32 -0500 (Fri, 06 Aug 2010) | 3 lines
Fix #9324: Add parameter validation to signal.signal on Windows in order
to prevent crashes.
........
Diffstat (limited to 'Modules/signalmodule.c')
-rw-r--r-- | Modules/signalmodule.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index e420a1b..251e67c 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -249,8 +249,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, |