mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
IFNAMSIZ is the maximum buffer size for an interface name, including its
terminating zero byte. [1] strncpy() should therefore only copy a size
of 'IFNAMSIZ - 1' and the destination string should then be
null-terminated properly.
Use util_strlcpy() to correctly copy the string and get rid of the
followin GCC8 compile warning:
In function ‘ethtool_checksumming’,
inlined from ‘process_sysfs_attribute’ at lsqeth.c:333:5,
inlined from ‘print_device’ at lsqeth.c:468:3:
lsqeth.c:171:2: warning: ‘strncpy’ specified bound 16 equals destination
size [-Wstringop-truncat ion]
strncpy(ifr.ifr_name, if_name, IFNAMSIZ);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[1]: https://www.gnu.org/software/libc/manual/html_node/Interface-Naming.html
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>