From b8022c8ad1e4af313c7086dfa9116278a9e57ac2 Mon Sep 17 00:00:00 2001 From: Matthias Klose Date: Sat, 20 Mar 2010 02:13:49 +0000 Subject: [PATCH] Merged revisions 79096 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ........ r79096 | matthias.klose | 2010-03-19 15:45:06 +0100 (Fr, 19 Mär 2010) | 2 lines - Issue #1039, #8154: Fix os.execlp() crash with missing 2nd argument. ........ --- Lib/test/test_os.py | 3 +++ Misc/NEWS | 2 ++ Modules/posixmodule.c | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 3cb411beff..45f6bd20ee 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -511,6 +511,9 @@ class URandomTests (unittest.TestCase): except NotImplementedError: pass + def test_execvpe_with_bad_arglist(self): + self.assertRaises(ValueError, os.execvpe, 'notepad', [], None) + class Win32ErrorTests(unittest.TestCase): def test_rename(self): self.assertRaises(WindowsError, os.rename, test_support.TESTFN, test_support.TESTFN+".bak") diff --git a/Misc/NEWS b/Misc/NEWS index 1fbf7c1cfb..9fd5f0887a 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -15,6 +15,8 @@ Core and Builtins Library ------- +- Issue #1039, #8154: Fix os.execlp() crash with missing 2nd argument. + - Issue #4961: Inconsistent/wrong result of askyesno function in tkMessageBox with Tcl/Tk-8.5. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 2ed54e4bdb..5add8481b8 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -2979,6 +2979,11 @@ posix_execv(PyObject *self, PyObject *args) PyMem_Free(path); return NULL; } + if (argc < 1) { + PyErr_SetString(PyExc_ValueError, "execv() arg 2 must not be empty"); + PyMem_Free(path); + return NULL; + } argvlist = PyMem_NEW(char *, argc+1); if (argvlist == NULL) { -- 2.50.1