[PATCH] strncpy -Wstringop-truncation in bfd/

John Reiser jreiser@bitwagon.com
Wed Feb 21 20:44:00 GMT 2018

Several uses of strncpy in bfd/* do not compile when using -Werror in gcc 8.0.x
because of -Wstringop-truncation.  A typical warning is:

    ../../binutils-gdb/libiberty/dyn-string.c:280:3: warning: ‘strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]

A work-around is to use 'memcpy' instead of 'strncpy'.  This spends
a few more cycles each time; but it compiles, and runs correctly
as long as the character arrays really are strings.  Patch is attached.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: strncpy-bfd.patch
Type: text/x-patch
Size: 5789 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20180221/58f2eff5/attachment.bin>

More information about the Binutils mailing list