dasdinfo: Replace strncpy() with util_strlcpy()

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 <hoeppner@linux.ibm.com>
This commit is contained in:
Jan Höppner
2018-11-06 11:17:27 +01:00
parent 83106991ab
commit cf39f26dee

View File

@@ -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");