Skip to content

Commit 1c743cd

Browse files
author
Dmitrii Chervov
committed
UCT/IB/BASE: Fix roce ndev name read
If a network interface name have a length of 15 (maximum allowed) and we are trying to read it to a buffer of 16 bytes size, here whats happen: 1) in function "ucs_read_file_str" MAX length will be decreased (now it is 15); 2) in function "ucs_read_file_vararg" there are "read" call that uses new MAX length (15) minus one (so it became 14). 3) If our name have maximum size we cannot read it fully, and it will be an error, becaus we cannot get it index from name. It is oblivious that first size decrease was for '\0' null byte, but the second is a bug. So i replaces "ucs_read_file_str" that do the negation to a "ucs_read_file" where it didn`t happening.
1 parent 532ed09 commit 1c743cd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/uct/ib/base/ib_device.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,9 +1499,9 @@ uct_ib_device_get_roce_ndev_name(uct_ib_device_t *dev, uint8_t port_num,
14991499
ucs_assert_always(uct_ib_device_is_port_roce(dev, port_num));
15001500

15011501
/* get the network device name which corresponds to a RoCE port */
1502-
nread = ucs_read_file_str(ndev_name, max, 1,
1503-
UCT_IB_DEVICE_SYSFS_GID_NDEV_FMT,
1504-
uct_ib_device_name(dev), port_num, gid_index);
1502+
nread = ucs_read_file(ndev_name, max, 1,
1503+
UCT_IB_DEVICE_SYSFS_GID_NDEV_FMT,
1504+
uct_ib_device_name(dev), port_num, gid_index);
15051505
if (nread < 0) {
15061506
ucs_diag("failed to read " UCT_IB_DEVICE_SYSFS_GID_NDEV_FMT": %m",
15071507
uct_ib_device_name(dev), port_num, 0);

0 commit comments

Comments
 (0)