mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
qethqoat: Use util_strlcpy() to copy strings
Use the more robust util_strlcpy() to copy strings instead of strncpy(). This fixes the following GCC8 compile warnings: qethqoat.c: In function ‘main’: qethqoat.c:616:2: warning: ‘strncpy’ specified bound 16 equals destination size [-Wstringop-truncation] strncpy(ifr.ifr_name, opts.ifname, IFNAMSIZ); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
@@ -2,7 +2,9 @@ include ../common.mak
|
||||
|
||||
all: qethqoat
|
||||
|
||||
qethqoat: qethqoat.o
|
||||
libs = $(rootdir)/libutil/libutil.a
|
||||
|
||||
qethqoat: qethqoat.o $(libs)
|
||||
|
||||
install: all
|
||||
$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man8
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/zt_common.h"
|
||||
#include "qethqoat.h"
|
||||
|
||||
@@ -541,6 +542,7 @@ int main(int argc, char **argv)
|
||||
opts.raw = 0;
|
||||
opts.scope = 1;
|
||||
opts.file = NULL;
|
||||
opts.ifname = NULL;
|
||||
|
||||
while ((c = getopt_long(argc, argv, qethqoat_opts_str, qethqoat_opts,
|
||||
&index)) != -1) {
|
||||
@@ -613,7 +615,7 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
strncpy(ifr.ifr_name, opts.ifname, IFNAMSIZ);
|
||||
util_strlcpy(ifr.ifr_name, opts.ifname, IFNAMSIZ);
|
||||
oat_data.command = opts.scope;
|
||||
ifr.ifr_ifru.ifru_data = (void *)&oat_data;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user