From: Victor Stinner Date: Mon, 14 Mar 2016 17:07:53 +0000 (+0100) Subject: posix_getcwd(): limit to INT_MAX on Windows X-Git-Tag: v3.6.0a1~479 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c44f70770bf629469a5a179b643e53dfeca884ad;p=thirdparty%2FPython%2Fcpython.git 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 ... --- diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 6e0081d0dff0..7e8987845bb6 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -3320,12 +3320,22 @@ posix_getcwd(int use_bytes) 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