]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Forbid an empty argument list in execv call.
authorThomas Heller <theller@ctypes.org>
Thu, 30 Aug 2007 17:15:14 +0000 (17:15 +0000)
committerThomas Heller <theller@ctypes.org>
Thu, 30 Aug 2007 17:15:14 +0000 (17:15 +0000)
Fixes issue 1039.

Lib/test/test_os.py
Modules/posixmodule.c

index a5f5de3698c473a45c3848c647e012c559ba48c1..085e6fabb8772b7cd7fd7effc60169afbf434607 100644 (file)
@@ -441,6 +441,9 @@ class ExecTests(unittest.TestCase):
     def test_execvpe_with_bad_program(self):
         self.assertRaises(OSError, os.execvpe, 'no such app-', [], None)
 
+    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 4e6e0c595db2a889f0eae5617f9816b70d59ebbe..5f8cde601081fd00feb104de817341274ba77e2c 100644 (file)
@@ -2834,6 +2834,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) {