STINNER Victor <victor.stin...@gmail.com> added the comment:

getpath.c uses many buffers of MAXPATHLEN+1 wide characters. Example:

    wchar_t argv0_path[MAXPATHLEN+1];

These buffers are initialized to zero to make sure that the last character is 
always a NULL character.

To keep the final NULL character, string copies use:

   wcsncpy(dest, src, MAXPATHLEN);

This code is wrong: it truncates the string if it's longer than MAXPATHLEN 
characters.

I modified the code to move global buffers closer to where there are used, and 
to dynamically allocate strings on the heap, rather using fixed sizes. But I 
didn't finish to "cleanup" Modules/getpath.c and PC/getpathp.c. The code still 
uses the buffer of fixed size and truncate strings.

The real fix would be to avoid these fixed-size buffers, and only use 
dynamically allocated strings.

I modified the code to allow to report errors. Previously, it wasn't possible 
exception using Py_FatalError() which is not a nice way to report errors, 
especially when Python is embedded in an application.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32375>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to