diff Python/import.c @ 63999:b7220e429abb

_Py_stat(): ensure that path ends with a nul character
author Victor Stinner <victor.stinner@haypocalc.com>
date Sat, 14 Aug 2010 16:59:08 +0000
parents 953010c0b168
children d360311f0e52
line wrap: on
line diff
--- a/Python/import.c	Sat Aug 14 16:56:27 2010 +0000
+++ b/Python/import.c	Sat Aug 14 16:59:08 2010 +0000
@@ -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;