]> granicus.if.org Git - python/commitdiff
_Py_stat(): ensure that path ends with a nul character
authorVictor Stinner <victor.stinner@haypocalc.com>
Sat, 14 Aug 2010 16:59:08 +0000 (16:59 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sat, 14 Aug 2010 16:59:08 +0000 (16:59 +0000)
Python/import.c

index 79a378e3c52b9e711603143d56722149cf45a69b..84ddc03c524706e374d18a7826283a529a99d4d6 100644 (file)
@@ -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;