Message308757
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. |
|
| Date |
User |
Action |
Args |
| 2017-12-20 18:02:13 | vstinner | set | recipients:
+ vstinner, pitrou, serhiy.storchaka |
| 2017-12-20 18:02:13 | vstinner | set | messageid: <1513792933.94.0.213398074469.issue32375@psf.upfronthosting.co.za> |
| 2017-12-20 18:02:13 | vstinner | link | issue32375 messages |
| 2017-12-20 18:02:13 | vstinner | create | |
|