Mercurial > cpython-lru_cache-weakref
comparison Python/sysmodule.c @ 61789:3f08d98c8fa5 2.6
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>`_.
........
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Fri, 21 May 2010 17:22:43 +0000 |
| parents | e38335d4df91 |
| children | 787b969d37f0 |
comparison
equal
deleted
inserted
replaced
| 61785:38719f11619b | 61789:3f08d98c8fa5 |
|---|---|
| 1526 } | 1526 } |
| 1527 return av; | 1527 return av; |
| 1528 } | 1528 } |
| 1529 | 1529 |
| 1530 void | 1530 void |
| 1531 PySys_SetArgv(int argc, char **argv) | 1531 PySys_SetArgvEx(int argc, char **argv, int updatepath) |
| 1532 { | 1532 { |
| 1533 #if defined(HAVE_REALPATH) | 1533 #if defined(HAVE_REALPATH) |
| 1534 char fullpath[MAXPATHLEN]; | 1534 char fullpath[MAXPATHLEN]; |
| 1535 #elif defined(MS_WINDOWS) && !defined(MS_WINCE) | 1535 #elif defined(MS_WINDOWS) && !defined(MS_WINCE) |
| 1536 char fullpath[MAX_PATH]; | 1536 char fullpath[MAX_PATH]; |
| 1539 PyObject *path = PySys_GetObject("path"); | 1539 PyObject *path = PySys_GetObject("path"); |
| 1540 if (av == NULL) | 1540 if (av == NULL) |
| 1541 Py_FatalError("no mem for sys.argv"); | 1541 Py_FatalError("no mem for sys.argv"); |
| 1542 if (PySys_SetObject("argv", av) != 0) | 1542 if (PySys_SetObject("argv", av) != 0) |
| 1543 Py_FatalError("can't assign sys.argv"); | 1543 Py_FatalError("can't assign sys.argv"); |
| 1544 if (path != NULL) { | 1544 if (updatepath && path != NULL) { |
| 1545 char *argv0 = argv[0]; | 1545 char *argv0 = argv[0]; |
| 1546 char *p = NULL; | 1546 char *p = NULL; |
| 1547 Py_ssize_t n = 0; | 1547 Py_ssize_t n = 0; |
| 1548 PyObject *a; | 1548 PyObject *a; |
| 1549 #ifdef HAVE_READLINK | 1549 #ifdef HAVE_READLINK |
| 1629 Py_DECREF(a); | 1629 Py_DECREF(a); |
| 1630 } | 1630 } |
| 1631 Py_DECREF(av); | 1631 Py_DECREF(av); |
| 1632 } | 1632 } |
| 1633 | 1633 |
| 1634 void | |
| 1635 PySys_SetArgv(int argc, char **argv) | |
| 1636 { | |
| 1637 PySys_SetArgvEx(argc, argv, 1); | |
| 1638 } | |
| 1639 | |
| 1634 | 1640 |
| 1635 /* APIs to write to sys.stdout or sys.stderr using a printf-like interface. | 1641 /* APIs to write to sys.stdout or sys.stderr using a printf-like interface. |
| 1636 Adapted from code submitted by Just van Rossum. | 1642 Adapted from code submitted by Just van Rossum. |
| 1637 | 1643 |
| 1638 PySys_WriteStdout(format, ...) | 1644 PySys_WriteStdout(format, ...) |
