This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug compile/22872] New: strncpy -Wstringop-truncation in bfd/


https://sourceware.org/bugzilla/show_bug.cgi?id=22872

            Bug ID: 22872
           Summary: strncpy -Wstringop-truncation in bfd/
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: compile
          Assignee: unassigned at sourceware dot org
          Reporter: jreiser at BitWagon dot com
  Target Milestone: ---

Created attachment 10841
  --> https://sourceware.org/bugzilla/attachment.cgi?id=10841&action=edit
use memcpy instead of strncpy in bfd/*

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]