summaryrefslogtreecommitdiffstats
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-05-21 17:25:34 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-05-21 17:25:34 (GMT)
commitf978facc0e81bed85c990612401a63954542aebc (patch)
tree1b11f141fe8898f94959e2ff9a1e23f4c5b33a9c /Python/sysmodule.c
parentcc6a982de8b9030a04d85f69a29772bf6c3f442f (diff)
downloadcpython-f978facc0e81bed85c990612401a63954542aebc.zip
cpython-f978facc0e81bed85c990612401a63954542aebc.tar.gz
cpython-f978facc0e81bed85c990612401a63954542aebc.tar.bz2
Merged revisions 81398 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81398 | antoine.pitrou | 2010-05-21 19:12:38 +0200 (ven., 21 mai 2010) | 6 lines Issue #5753: A new C API function, :cfunc:`PySys_SetArgvEx`, allows embedders of the interpreter to set sys.argv without also modifying sys.path. This helps fix `CVE-2008-5983 <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5983>`_. ........
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index ce06d7d..77b120f 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1668,7 +1668,7 @@ _wrealpath(const wchar_t *path, wchar_t *resolved_path)
#endif
void
-PySys_SetArgv(int argc, wchar_t **argv)
+PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath)
{
#if defined(HAVE_REALPATH)
wchar_t fullpath[MAXPATHLEN];
@@ -1681,7 +1681,7 @@ PySys_SetArgv(int argc, wchar_t **argv)
Py_FatalError("no mem for sys.argv");
if (PySys_SetObject("argv", av) != 0)
Py_FatalError("can't assign sys.argv");
- if (path != NULL) {
+ if (updatepath && path != NULL) {
wchar_t *argv0 = argv[0];
wchar_t *p = NULL;
Py_ssize_t n = 0;
@@ -1768,6 +1768,12 @@ PySys_SetArgv(int argc, wchar_t **argv)
Py_DECREF(av);
}
+void
+PySys_SetArgv(int argc, wchar_t **argv)
+{
+ PySys_SetArgvEx(argc, argv, 1);
+}
+
/* Reimplementation of PyFile_WriteString() no calling indirectly
PyErr_CheckSignals(): avoid the call to PyObject_Str(). */