kdb: Use strscpy with destination buffer size
authorPrarit Bhargava <prarit@redhat.com>
Thu, 20 Sep 2018 12:59:14 +0000 (08:59 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 1 Dec 2018 08:47:59 +0000 (09:47 +0100)
commit1bdb2d2f065be2d4a41eca784feb7abad4e25c1a
tree0f7a5086c5c461885409e444a0adcaa5d8d0435e
parent6093733eca0e103fc389227ed6e30557d2f26d21
kdb: Use strscpy with destination buffer size

[ Upstream commit c2b94c72d93d0929f48157eef128c4f9d2e603ce ]

gcc 8.1.0 warns with:

kernel/debug/kdb/kdb_support.c: In function ‘kallsyms_symbol_next’:
kernel/debug/kdb/kdb_support.c:239:4: warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=]
     strncpy(prefix_name, name, strlen(name)+1);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/debug/kdb/kdb_support.c:239:31: note: length computed here

Use strscpy() with the destination buffer size, and use ellipses when
displaying truncated symbols.

v2: Use strscpy()

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: Jonathan Toppins <jtoppins@redhat.com>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Daniel Thompson <daniel.thompson@linaro.org>
Cc: kgdb-bugreport@lists.sourceforge.net
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/debug/kdb/kdb_io.c
kernel/debug/kdb/kdb_private.h
kernel/debug/kdb/kdb_support.c