◐ Shell
clean mode source ↗

Message 308697 - Python tracker

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?