Skip to content

Commit 9d68f46

Browse files
committed
opal/util/ethtool.c: fix interface name len
Per a comment in opal/util/if.h, we hard-code OPAL_IF_NAMESIZE to 32 -- regardless of what the underlying IF_NAMESIZE is. On some Linux systems, IF_NAMESIZE if 16, leading to a potential memory overrun when we copy the interface name. In practice, this probably wouldn't happen because we use opal_string_copy(), which will only copy up to the terminating \0, and Linux network interface names will always have a terminating \0. But we might as well be defensive, and use the underlying IF_NAMESIZE (this file already includes <net/if.h>, where that should be defined). Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
1 parent ebeca1d commit 9d68f46

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

opal/util/ethtool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2016 Karol Mroz. All rights reserved.
33
* Copyright (c) 2016 Research Organization for Information Science
44
* and Technology (RIST). All rights reserved.
5-
* Copyright (c) 2016 Cisco Systems, Inc. All rights reserved.
5+
* Copyright (c) 2016-2022 Cisco Systems, Inc. All rights reserved.
66
* $COPYRIGHT$
77
*
88
* Additional copyrights may follow
@@ -63,7 +63,7 @@ unsigned int opal_ethtool_get_speed(const char *if_name)
6363
}
6464

6565
memset(&ifr, 0, sizeof(struct ifreq));
66-
opal_string_copy(ifr.ifr_name, if_name, OPAL_IF_NAMESIZE);
66+
opal_string_copy(ifr.ifr_name, if_name, IF_NAMESIZE);
6767
ifr.ifr_data = (char *) &edata;
6868

6969
if (ioctl(sockfd, SIOCETHTOOL, &ifr) < 0) {

0 commit comments

Comments
 (0)