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>
The term 'len' only represents the number of characters in a string,
as opposed to 'size' which means the number of bytes including the
terminating null byte ('\0').
DEV_NAME_LEN is defined as IFNAMSIZ, so we are clearly interested in the
size. Rename to DEV_NAME_SIZE to make this more clear.
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is based on the s390-tools-1.39.0 version.
Changes on top of s390-tools-1.39.0:
- Add MIT license to all source files
- Add LICENSE file
- Transform REAMDE to README.md (markdown)
- Add AUTHORS.md file
- Add CONTRIBUTING.md file
- Move changelog from README to CHANGELOG.md file
Reviewed-by: Stefan Haberland <sth@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>