[Python-checkins] cpython: posix_getcwd(): limit to INT_MAX on Windows
victor.stinner
python-checkins at python.org
Mon Mar 14 13:09:18 EDT 2016
https://hg.python.org/cpython/rev/4676c9b370a0
changeset: 100532:4676c9b370a0
parent: 100530:9caf236cbe6d
user: Victor Stinner <victor.stinner at gmail.com>
date: Mon Mar 14 18:07:53 2016 +0100
summary:
posix_getcwd(): limit to INT_MAX on Windows
It's more to fix a conversion warning during compilation, I don't think that
Windows support current working directory larger than 2 GB ...
files:
Modules/posixmodule.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -3320,12 +3320,22 @@
Py_BEGIN_ALLOW_THREADS
do {
buflen += chunk;
+#ifdef MS_WINDOWS
+ if (buflen > INT_MAX) {
+ PyErr_NoMemory();
+ break;
+ }
+#endif
tmpbuf = PyMem_RawRealloc(buf, buflen);
if (tmpbuf == NULL)
break;
buf = tmpbuf;
+#ifdef MS_WINDOWS
+ cwd = getcwd(buf, (int)buflen);
+#else
cwd = getcwd(buf, buflen);
+#endif
} while (cwd == NULL && errno == ERANGE);
Py_END_ALLOW_THREADS
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list