summaryrefslogtreecommitdiffstats
path: root/Python/import.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-08-14 16:59:08 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-08-14 16:59:08 (GMT)
commit8a79dccc48a5d8ab27bc2f43c2dd3fc467efe71c (patch)
treedecba7d895364f02ebe02d9bd4a9c42cc9f77f08 /Python/import.c
parent09245d8682c00fdf70c45eecc2891d4f9f7275c6 (diff)
downloadcpython-8a79dccc48a5d8ab27bc2f43c2dd3fc467efe71c.zip
cpython-8a79dccc48a5d8ab27bc2f43c2dd3fc467efe71c.tar.gz
cpython-8a79dccc48a5d8ab27bc2f43c2dd3fc467efe71c.tar.bz2
_Py_stat(): ensure that path ends with a nul character
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/import.c b/Python/import.c
index 79a378e..84ddc03 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1976,10 +1976,11 @@ _Py_stat(PyObject *unicode, struct stat *statbuf)
int err;
struct _stat wstatbuf;
- len = PyUnicode_AsWideChar((PyUnicodeObject*)unicode, path,
- sizeof(path) / sizeof(path[0]));
+ len = PyUnicode_AsWideChar((PyUnicodeObject*)unicode, path, MAXPATHLEN);
if (len == -1)
return -1;
+ path[len] = L'\0';
+
err = _wstat(path, &wstatbuf);
if (!err)
statbuf->st_mode = wstatbuf.st_mode;