diff options
author | Steve Dower <steve.dower@microsoft.com> | 2016-11-19 18:33:39 -0800 |
---|---|---|
committer | Steve Dower <steve.dower@microsoft.com> | 2016-11-19 18:33:39 -0800 |
commit | fdaacf7baf8f82b2fe6623375ec9b4a998d8b03e (patch) | |
tree | 18d610fa5521ed0d7e660c3cfef666d08b9e95fc /Modules | |
parent | 4833433f4062a7edfbd0e23e672fd9128f83621a (diff) | |
download | cpython-fdaacf7baf8f82b2fe6623375ec9b4a998d8b03e.tar.gz |
Issue #28732: Fix crash in os.spawnv() with no elements in args
Prevents crashes in some other posixmodule.c functions
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/posixmodule.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 5a23824a1a..6170ff7f79 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5186,6 +5186,16 @@ os_spawnv_impl(PyObject *module, int mode, PyObject *path, PyObject *argv) "spawnv() arg 2 must be a tuple or list"); return NULL; } +#ifdef MS_WINDOWS + /* Avoid changing behavior in maintenance release, but + the previous Windows behavior was to crash, so this + is a "compatible" improvement. */ + if (argc == 0) { + PyErr_SetString(PyExc_ValueError, + "spawnv() arg 2 cannot be empty"); + return NULL; + } +#endif argvlist = PyMem_NEW(char *, argc+1); if (argvlist == NULL) { @@ -5207,7 +5217,9 @@ os_spawnv_impl(PyObject *module, int mode, PyObject *path, PyObject *argv) mode = _P_OVERLAY; Py_BEGIN_ALLOW_THREADS + _Py_BEGIN_SUPPRESS_IPH spawnval = _spawnv(mode, path_char, argvlist); + _Py_END_SUPPRESS_IPH Py_END_ALLOW_THREADS free_string_array(argvlist, argc); @@ -5297,7 +5309,9 @@ os_spawnve_impl(PyObject *module, int mode, PyObject *path, PyObject *argv, mode = _P_OVERLAY; Py_BEGIN_ALLOW_THREADS + _Py_BEGIN_SUPPRESS_IPH spawnval = _spawnve(mode, path_char, argvlist, envlist); + _Py_END_SUPPRESS_IPH Py_END_ALLOW_THREADS if (spawnval == -1) @@ -7022,7 +7036,9 @@ os_waitpid_impl(PyObject *module, Py_intptr_t pid, int options) do { Py_BEGIN_ALLOW_THREADS + _Py_BEGIN_SUPPRESS_IPH res = _cwait(&status, pid, options); + _Py_END_SUPPRESS_IPH Py_END_ALLOW_THREADS } while (res < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals())); if (res < 0) |