Kaydet (Commit) 015f4d87 authored tarafından Victor Stinner's avatar Victor Stinner

_Py_wrealpath() requires the size of the output buffer

üst a4a75951
...@@ -41,7 +41,8 @@ PyAPI_FUNC(int) _Py_wreadlink( ...@@ -41,7 +41,8 @@ PyAPI_FUNC(int) _Py_wreadlink(
#ifdef HAVE_REALPATH #ifdef HAVE_REALPATH
PyAPI_FUNC(wchar_t*) _Py_wrealpath( PyAPI_FUNC(wchar_t*) _Py_wrealpath(
const wchar_t *path, const wchar_t *path,
wchar_t *resolved_path); wchar_t *resolved_path,
size_t resolved_path_size);
#endif #endif
PyAPI_FUNC(wchar_t*) _Py_wgetcwd( PyAPI_FUNC(wchar_t*) _Py_wgetcwd(
......
...@@ -321,7 +321,8 @@ _Py_wreadlink(const wchar_t *path, wchar_t *buf, size_t bufsiz) ...@@ -321,7 +321,8 @@ _Py_wreadlink(const wchar_t *path, wchar_t *buf, size_t bufsiz)
#ifdef HAVE_REALPATH #ifdef HAVE_REALPATH
wchar_t* wchar_t*
_Py_wrealpath(const wchar_t *path, wchar_t *resolved_path) _Py_wrealpath(const wchar_t *path,
wchar_t *resolved_path, size_t resolved_path_size)
{ {
char *cpath; char *cpath;
char cresolved_path[PATH_MAX]; char cresolved_path[PATH_MAX];
...@@ -336,7 +337,7 @@ _Py_wrealpath(const wchar_t *path, wchar_t *resolved_path) ...@@ -336,7 +337,7 @@ _Py_wrealpath(const wchar_t *path, wchar_t *resolved_path)
PyMem_Free(cpath); PyMem_Free(cpath);
if (res == NULL) if (res == NULL)
return NULL; return NULL;
r = mbstowcs(resolved_path, cresolved_path, PATH_MAX); r = mbstowcs(resolved_path, cresolved_path, resolved_path_size);
if (r == (size_t)-1 || r >= PATH_MAX) { if (r == (size_t)-1 || r >= PATH_MAX) {
errno = EINVAL; errno = EINVAL;
return NULL; return NULL;
......
...@@ -1742,7 +1742,7 @@ sys_update_path(int argc, wchar_t **argv) ...@@ -1742,7 +1742,7 @@ sys_update_path(int argc, wchar_t **argv)
#else /* All other filename syntaxes */ #else /* All other filename syntaxes */
if (_HAVE_SCRIPT_ARGUMENT(argc, argv)) { if (_HAVE_SCRIPT_ARGUMENT(argc, argv)) {
#if defined(HAVE_REALPATH) #if defined(HAVE_REALPATH)
if (_Py_wrealpath(argv0, fullpath)) { if (_Py_wrealpath(argv0, fullpath, PATH_MAX)) {
argv0 = fullpath; argv0 = fullpath;
} }
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment