diff options
author | Stefan Krah <stefan@bytereef.org> | 2010-07-19 15:43:23 (GMT) |
---|---|---|
committer | Stefan Krah <stefan@bytereef.org> | 2010-07-19 15:43:23 (GMT) |
commit | 36db84d3db862bfe8d8f56882fa51d3dc151e638 (patch) | |
tree | c839b6afed89db7db5bf00b313d1d5ea5038b67c /Modules | |
parent | 9ea629cc836682d52eb7da21900ef335a77344c8 (diff) | |
download | cpython-36db84d3db862bfe8d8f56882fa51d3dc151e638.zip cpython-36db84d3db862bfe8d8f56882fa51d3dc151e638.tar.gz cpython-36db84d3db862bfe8d8f56882fa51d3dc151e638.tar.bz2 |
Merged revisions 82853-82854 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/release27-maint
........
r82853 | stefan.krah | 2010-07-13 21:17:08 +0200 (Tue, 13 Jul 2010) | 4 lines
Issue #9185: On Solaris and OpenBSD, posix_getcwd() could loop indefinitely
if the path length exceeded PATH_MAX.
........
r82854 | stefan.krah | 2010-07-13 21:40:00 +0200 (Tue, 13 Jul 2010) | 3 lines
Remove PYOS_OS2 special cases from the Solaris/OpenBSD section.
........
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/posixmodule.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 46ee716..a7f7382 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1970,6 +1970,24 @@ PyDoc_STRVAR(posix_getcwd__doc__, "getcwd() -> path\n\n\ Return a string representing the current working directory."); +#if (defined(__sun) && defined(__SVR4)) || defined(__OpenBSD__) +/* Issue 9185: getcwd() returns NULL/ERANGE indefinitely. */ +static PyObject * +posix_getcwd(PyObject *self, PyObject *noargs) +{ + char buf[PATH_MAX+2]; + char *res; + + Py_BEGIN_ALLOW_THREADS + res = getcwd(buf, sizeof buf); + Py_END_ALLOW_THREADS + + if (res == NULL) + return posix_error(); + + return PyString_FromString(buf); +} +#else static PyObject * posix_getcwd(PyObject *self, PyObject *noargs) { @@ -2006,6 +2024,7 @@ posix_getcwd(PyObject *self, PyObject *noargs) return dynamic_return; } +#endif /* getcwd() NULL/ERANGE workaround. */ #ifdef Py_USING_UNICODE PyDoc_STRVAR(posix_getcwdu__doc__, |