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.00:25:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1513729558.64.0.213398074469.issue32375@psf.upfronthosting.co.za>
In-reply-to
Content
In function ‘wcsncpy’,
    inlined from ‘calculate_zip_path’ at ./Modules/getpath.c:797:5:
/usr/include/x86_64-linux-gnu/bits/wchar2.h:200:9: warning: call to ‘__wcsncpy_chk_warn’ declared with attribute warning: wcsncpy called with length bigger than size of destination buffer
  return __wcsncpy_chk_warn (__dest, __src, __n,
         ^

Line 797:

    wcsncpy(calculate->zip_path, prefix, MAXPATHLEN);

calculate type is "PyCalculatePath *" which is defined as:

typedef struct {
    ...
    wchar_t zip_path[MAXPATHLEN+1];    /* ".../lib/pythonXY.zip" */
    ...
} PyCalculatePath;

Earlier, all bytes are set to 0:

    memset(&calculate, 0, sizeof(calculate));

So I don't see how wcsncpy() can overflow.


By the way, I'm unable to reproduce the warning on Fedora 27 with GCC 7.2.1. Are you using -D_FORTIFY_SOURCE=1? Are you compiling Python in release mode? Can you try to find the command line compiling getpath.c?
History
Date User Action Args
2017-12-20 00:25:58vstinnersetrecipients: + vstinner, pitrou, serhiy.storchaka
2017-12-20 00:25:58vstinnersetmessageid: <1513729558.64.0.213398074469.issue32375@psf.upfronthosting.co.za>
2017-12-20 00:25:58vstinnerlinkissue32375 messages
2017-12-20 00:25:58vstinnercreate