[Bug c/81117] Improve buffer overflow checking in strncpy
dimhen at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Nov 13 08:37:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81117
--- Comment #12 from Dmitry G. Dyachenko <dimhen at gmail dot com> ---
char *strncpy(char *dest, const char *src, size_t n);
void foo(char* p)
{
strncpy(p, "1", 1);
p[1] = 0;
}
with gcc8/r254663 is this expected?
$ gcc -c -Wall x.c
x.c: In function ‘foo’:
x.c:4:5: warning: ‘strncpy’ output truncated before terminating nul copying 1
byte from a string of the same length [-Wstringop-truncation]
strncpy(p, "1", 1);
^~~~~~~~~~~~~~~~~~
More information about the Gcc-bugs
mailing list