mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
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 ...
This commit is contained in:
parent
3719779765
commit
c44f70770b
1 changed files with 10 additions and 0 deletions
|
@ -3320,12 +3320,22 @@ posix_getcwd(int use_bytes)
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
do {
|
do {
|
||||||
buflen += chunk;
|
buflen += chunk;
|
||||||
|
#ifdef MS_WINDOWS
|
||||||
|
if (buflen > INT_MAX) {
|
||||||
|
PyErr_NoMemory();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
tmpbuf = PyMem_RawRealloc(buf, buflen);
|
tmpbuf = PyMem_RawRealloc(buf, buflen);
|
||||||
if (tmpbuf == NULL)
|
if (tmpbuf == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
buf = tmpbuf;
|
buf = tmpbuf;
|
||||||
|
#ifdef MS_WINDOWS
|
||||||
|
cwd = getcwd(buf, (int)buflen);
|
||||||
|
#else
|
||||||
cwd = getcwd(buf, buflen);
|
cwd = getcwd(buf, buflen);
|
||||||
|
#endif
|
||||||
} while (cwd == NULL && errno == ERANGE);
|
} while (cwd == NULL && errno == ERANGE);
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue