[issue19636] Fix usage of MAX_PATH in posixmodule.c

STINNER Victor report at bugs.python.org
Mon Nov 18 00:52:11 CET 2013


STINNER Victor added the comment:

posix__getfullpathname():

-    char outbuf[MAX_PATH*2];
+    char outbuf[MAX_PATH];
...
-        wchar_t woutbuf[MAX_PATH*2], *woutbufp = woutbuf;
+        wchar_t woutbuf[MAX_PATH], *woutbufp = woutbuf;

I don't know what "*2" was used here, probably a mistake with sizeof(wchar_t)=2? (try to allocate bytes, where the length is a number of wide characters)


posix__getvolumepathname() is new in Python 3.4, so not need to backport its fix.


path_converter():

     length = PyBytes_GET_SIZE(bytes);
 #ifdef MS_WINDOWS
-    if (length > MAX_PATH) {
+    if (length > MAX_PATH-1) {
         FORMAT_EXCEPTION(PyExc_ValueError, "%s too long for Windows");
         Py_DECREF(bytes);
         return 0;

I don't know if this fix should be backported to Python 3.3.

----------
components: +Windows

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19636>
_______________________________________


More information about the Python-bugs-list mailing list