[Python-checkins] r85308 - in python/branches/py3k: Include/fileutils.h Python/fileutils.c Python/sysmodule.c
victor.stinner
python-checkins at python.org
Fri Oct 8 00:29:53 CEST 2010
Author: victor.stinner
Date: Fri Oct 8 00:29:53 2010
New Revision: 85308
Log:
_Py_wrealpath() requires the size of the output buffer
Modified:
python/branches/py3k/Include/fileutils.h
python/branches/py3k/Python/fileutils.c
python/branches/py3k/Python/sysmodule.c
Modified: python/branches/py3k/Include/fileutils.h
==============================================================================
--- python/branches/py3k/Include/fileutils.h (original)
+++ python/branches/py3k/Include/fileutils.h Fri Oct 8 00:29:53 2010
@@ -41,7 +41,8 @@
#ifdef HAVE_REALPATH
PyAPI_FUNC(wchar_t*) _Py_wrealpath(
const wchar_t *path,
- wchar_t *resolved_path);
+ wchar_t *resolved_path,
+ size_t resolved_path_size);
#endif
PyAPI_FUNC(wchar_t*) _Py_wgetcwd(
Modified: python/branches/py3k/Python/fileutils.c
==============================================================================
--- python/branches/py3k/Python/fileutils.c (original)
+++ python/branches/py3k/Python/fileutils.c Fri Oct 8 00:29:53 2010
@@ -321,7 +321,8 @@
#ifdef HAVE_REALPATH
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 cresolved_path[PATH_MAX];
@@ -336,7 +337,7 @@
PyMem_Free(cpath);
if (res == 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) {
errno = EINVAL;
return NULL;
Modified: python/branches/py3k/Python/sysmodule.c
==============================================================================
--- python/branches/py3k/Python/sysmodule.c (original)
+++ python/branches/py3k/Python/sysmodule.c Fri Oct 8 00:29:53 2010
@@ -1742,7 +1742,7 @@
#else /* All other filename syntaxes */
if (_HAVE_SCRIPT_ARGUMENT(argc, argv)) {
#if defined(HAVE_REALPATH)
- if (_Py_wrealpath(argv0, fullpath)) {
+ if (_Py_wrealpath(argv0, fullpath, PATH_MAX)) {
argv0 = fullpath;
}
#endif
More information about the Python-checkins
mailing list