ToT build failure with ToT GCC (strncpy warning)
Florian Weimer
fweimer@redhat.com
Mon Nov 13 16:30:00 GMT 2017
On 11/13/2017 05:28 PM, Steve Ellcey wrote:
>
> A recent change to GCC has caused a glibc build failure.  The GCC
> change was for strncpy buffer overflow checking (PR c/81117 in the GCC
> bugzilla).  The resulting glibc build failure is:
>
> ../sysdeps/unix/sysv/linux/if_index.c:46:3: error: âstrncpyâ specified
> bound 16 equals destination size [-Werror=stringop-truncation]
> Â Â Â strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
> Â Â Â ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> It looks like GCC ran into this themselves and their fix was to change
> the strncpy call to memcpy.  The glibc breakage is also noted in GCC
> bug bootstrap/82948 but I don't see it mentioned in the glibc mailing
> lsit anywhere.
>
> Does changing the strncpy call here to memcpy sound like the right fix?
See the existing thread â[PATCH] add attribute nonstringâ.
Thanks,
Florian
More information about the Libc-alpha
mailing list