From cf39f26dee4b34245cac662d7684bfe34e343dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B6ppner?= Date: Tue, 6 Nov 2018 11:17:27 +0100 Subject: [PATCH] dasdinfo: Replace strncpy() with util_strlcpy() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Copy strings correctly by using util_strlcpy() over strncpy() and get rid of the following GCC8 compile warning: In function ‘dinfo_extract_dev’, inlined from ‘dinfo_get_dev_from_blockdev’ at dasdinfo.c:365:6: dasdinfo.c:337:2: warning: ‘strncpy’ specified bound 80 equals destination size [-Wstringop-trunc ation] strncpy(tmp, str, RD_BUFFER_SIZE); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Jan Höppner --- dasdinfo/dasdinfo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dasdinfo/dasdinfo.c b/dasdinfo/dasdinfo.c index 0c585f3f..3d46e3b5 100644 --- a/dasdinfo/dasdinfo.c +++ b/dasdinfo/dasdinfo.c @@ -25,6 +25,7 @@ #include "lib/dasd_base.h" #include "lib/util_base.h" #include "lib/util_file.h" +#include "lib/util_libc.h" #include "lib/util_opt.h" #include "lib/util_prg.h" #include "lib/zt_common.h" @@ -334,7 +335,7 @@ static int dinfo_extract_dev(dev_t *dev, char *str) int ma, mi; bzero(tmp, RD_BUFFER_SIZE); - strncpy(tmp, str, RD_BUFFER_SIZE); + util_strlcpy(tmp, str, RD_BUFFER_SIZE); p = strchr(tmp, ':'); if (p == NULL) { warnx("Error: unable to extract major/minor");