[Python-checkins] r84026 - python/branches/py3k/Python/import.c

victor.stinner python-checkins at python.org
Sat Aug 14 18:59:08 CEST 2010


Author: victor.stinner
Date: Sat Aug 14 18:59:08 2010
New Revision: 84026

Log:
_Py_stat(): ensure that path ends with a nul character


Modified:
   python/branches/py3k/Python/import.c

Modified: python/branches/py3k/Python/import.c
==============================================================================
--- python/branches/py3k/Python/import.c	(original)
+++ python/branches/py3k/Python/import.c	Sat Aug 14 18:59:08 2010
@@ -1976,10 +1976,11 @@
     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;


More information about the Python-checkins mailing list