From: Victor Stinner Date: Sat, 14 Aug 2010 16:59:08 +0000 (+0000) Subject: _Py_stat(): ensure that path ends with a nul character X-Git-Tag: v3.2a2~322 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8a79dccc48a5d8ab27bc2f43c2dd3fc467efe71c;p=python _Py_stat(): ensure that path ends with a nul character --- diff --git a/Python/import.c b/Python/import.c index 79a378e3c5..84ddc03c52 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;