]> granicus.if.org Git - python/commitdiff
- Issue #1039, #8154: Fix os.execlp() crash with missing 2nd argument.
authorMatthias Klose <doko@ubuntu.com>
Fri, 19 Mar 2010 14:45:06 +0000 (14:45 +0000)
committerMatthias Klose <doko@ubuntu.com>
Fri, 19 Mar 2010 14:45:06 +0000 (14:45 +0000)
Lib/test/test_os.py
Misc/NEWS
Modules/posixmodule.c

index 3dd7f90464401104bb771cd80d3a9e8e1243480d..4e21dd8de351044829e6e6700215f198f685ac74 100644 (file)
@@ -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")
index 95ff3495f6fe20a5afdfaa85349359b6bbe071f3..4221ee2aad6cc1ef996a78be87b7af5cafa10eb2 100644 (file)
--- 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.
index f729e88dab1372f51a5dce26f91e00f43f0ba822..8fb7aaab2c2265f7a586da4884a42b6ede495a9f 100644 (file)
@@ -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) {