This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients pitrou, serhiy.storchaka, vstinner
Date 2017-12-20.18:02:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1513792933.94.0.213398074469.issue32375@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-12-20 18:02:13vstinnersetrecipients: + vstinner, pitrou, serhiy.storchaka
2017-12-20 18:02:13vstinnersetmessageid: <1513792933.94.0.213398074469.issue32375@psf.upfronthosting.co.za>
2017-12-20 18:02:13vstinnerlinkissue32375 messages
2017-12-20 18:02:13vstinnercreate
Morty Proxy This is a proxified and sanitized view of the page, visit original site.