dwarf.c: string_fortify.h strncpy error
authorAlan Modra <amodra@gmail.com>
Fri, 18 Jun 2021 08:54:43 +0000 (18:24 +0930)
committerAlan Modra <amodra@gmail.com>
Sat, 19 Jun 2021 01:38:00 +0000 (11:08 +0930)
commit539b54f03dd082c572308246e610e516ff96b5b1
treed5c7eb8cc110c302581899452756974d75e70e39
parent8ee63c615688aeb997d01129a037068e606351bd
dwarf.c: string_fortify.h strncpy error

In function 'strncpy',
    inlined from 'display_debug_lines_decoded' at /home/alan/src/binutils-gdb/binutils/dwarf.c:5434:5,
    inlined from 'display_debug_lines' at /home/alan/src/binutils-gdb/binutils/dwarf.c:5567:21:
/usr/include/bits/string_fortified.h:95:10: error: '__builtin_strncpy' specified bound 36 equals destination size [-Werror=stringop-truncation]

No need for strncpy here, the string being copied always fits the
destination buffer.

* dwarf.c (display_debug_lines_decoded): Use memcpy rather than
strncpy when trimming file name length to MAX_FILENAME_LENGTH.
Don't make an unnecessary copy when length is good.
binutils/ChangeLog
binutils/dwarf.c