mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
DEV_NAME_SIZE is defined as IFNAMSIZ. IFNAMSIZ is the maximum buffer size for an interface name, including its terminating null byte. [1] The buffers dev_name and ifr_name are both defined with a size of DEV_NAME_SIZE and IFNAMSIZ respectively. Given these facts, only a size of 'IFNAMSIZ - 1' should be copied and the destination string should then be null-terminated properly. Use util_strlcpy() to correctly copy the strings and rid of the followin GCC8 compile warnings: xcec-bridge.c: In function ‘open_incoming_socket’: xcec-bridge.c:94:2: warning: ‘strncpy’ specified bound 16 equals destination size [-Wstringop-tru ncation] ..strncpy(if_req.ifr_name,dev_name,DEV_NAME_LEN); ..^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ xcec-bridge.c: In function ‘read_sys’: xcec-bridge.c:284:4: warning: ‘strncpy’ output may be truncated copying 16 bytes from a string of length 255 [-Wstringop-truncation] ....strncpy(is->dev_name, if_name, DEV_NAME_LEN); ....^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [1]: https://www.gnu.org/software/libc/manual/html_node/Interface-Naming.html Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>