From 828cd98cf8ba5f8f93ce7e5296dd4175675dcbcc Mon Sep 17 00:00:00 2001 From: Robert Burger Date: Tue, 24 Sep 2024 06:44:50 +0200 Subject: [PATCH] fix: interface name length on copy to ifreq --- src/hw_sock_raw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hw_sock_raw.c b/src/hw_sock_raw.c index f708c6d..df9c55a 100644 --- a/src/hw_sock_raw.c +++ b/src/hw_sock_raw.c @@ -198,7 +198,7 @@ int hw_device_sock_raw_open(struct hw_sock_raw *phw_sock_raw, struct ec *pec, co ec_log(10, "HW_OPEN", "binding raw socket to %s\n", devname); (void)memset(&ifr, 0, sizeof(ifr)); - (void)strncpy(ifr.ifr_name, devname, IFNAMSIZ); + (void)strncpy(ifr.ifr_name, devname, min(strlen(devname), IFNAMSIZ)); ioctl(phw_sock_raw->sockfd, SIOCGIFMTU, &ifr); phw_sock_raw->common.mtu_size = ifr.ifr_mtu; ec_log(10, "hw_open", "got mtu size %d\n", phw_sock_raw->common.mtu_size);