summaryrefslogtreecommitdiffstats
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-05-21 17:22:43 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-05-21 17:22:43 (GMT)
commit52ca516cacf75b430d399d638c1e00b49b0bb564 (patch)
tree95b1f0eacea0a7bc72024ce5c1cf42cfd31f9642 /Python/sysmodule.c
parent0a3b69ef0a8aa075bc0391f05b268095a77cda87 (diff)
downloadcpython-52ca516cacf75b430d399d638c1e00b49b0bb564.zip
cpython-52ca516cacf75b430d399d638c1e00b49b0bb564.tar.gz
cpython-52ca516cacf75b430d399d638c1e00b49b0bb564.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 6aa3cdb..91fe224 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1528,7 +1528,7 @@ makeargvobject(int argc, char **argv)
}
void
-PySys_SetArgv(int argc, char **argv)
+PySys_SetArgvEx(int argc, char **argv, int updatepath)
{
#if defined(HAVE_REALPATH)
char fullpath[MAXPATHLEN];
@@ -1541,7 +1541,7 @@ PySys_SetArgv(int argc, char **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) {
char *argv0 = argv[0];
char *p = NULL;
Py_ssize_t n = 0;
@@ -1631,6 +1631,12 @@ PySys_SetArgv(int argc, char **argv)
Py_DECREF(av);
}
+void
+PySys_SetArgv(int argc, char **argv)
+{
+ PySys_SetArgvEx(argc, argv, 1);
+}
+
/* APIs to write to sys.stdout or sys.stderr using a printf-like interface.
Adapted from code submitted by Just van Rossum.