From: Matthias Klose Date: Fri, 19 Mar 2010 14:45:06 +0000 (+0000) Subject: - Issue #1039, #8154: Fix os.execlp() crash with missing 2nd argument. X-Git-Tag: v2.7b1~315 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e9fbf2b943d79e8d8d71b64c1881829af880229d;p=python - Issue #1039, #8154: Fix os.execlp() crash with missing 2nd argument. --- diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 3dd7f90464..4e21dd8de3 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -505,6 +505,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 95ff3495f6..4221ee2aad 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -63,6 +63,8 @@ Library Extension Modules ----------------- +- Issue #1039, #8154: Fix os.execlp() crash with missing 2nd argument. + - Issue #6949: Allow the _bsddb extension to be built with db-4.8.x. - Issue #8142: Update libffi to the 3.0.9 release. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index f729e88dab..8fb7aaab2c 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -2952,6 +2952,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) {