target/s390x/arch_dump: Fix warning for the name field in the PT_NOTE section
commitea1b90b4fcb1230b2c85f3fd4ee09a84ddca7a6f
authorThomas Huth <thuth@redhat.com>
Fri, 5 Feb 2021 09:39:21 +0000 (5 10:39 +0100)
committerCornelia Huck <cohuck@redhat.com>
Thu, 4 Mar 2021 10:23:35 +0000 (4 11:23 +0100)
tree3ce77900d8452063e90a371f0b05512a11bf139b
parent0110253e690f37ff0add0c8d75f47747041d75fa
target/s390x/arch_dump: Fix warning for the name field in the PT_NOTE section

There is a compiler warning with GCC 9.3 when compiling with
the -fsanitize=thread compiler flag:

 In function 'strncpy',
    inlined from 's390x_write_elf64_notes' at ../target/s390x/arch_dump.c:219:9:
 /usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error:
  '__builtin_strncpy' specified bound 8 equals destination size
  [-Werror=stringop-truncation]

Since the name should always be NUL-terminated, let's use g_strlcpy() to
silence this warning. And while we're at it, also add an assert() to make
sure that the provided names always fit the size field (which is fine for
the current callers, the function is called once with "CORE" and once with
"LINUX" as a name).

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Message-Id: <20210205093921.848260-1-thuth@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
target/s390x/arch_dump.c