Skip to content

Commit

Permalink
fix: strncpy on ifr_name
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-burger committed Nov 29, 2024
1 parent a25627d commit 60fc7e7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/hw_sock_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, min(strlen(devname), IFNAMSIZ));
(void)strncpy(ifr.ifr_name, devname, min(strlen(devname), IFNAMSIZ - 1));
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);
Expand Down
2 changes: 1 addition & 1 deletion src/hw_sock_raw_mmaped.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ int hw_device_sock_raw_mmaped_open(struct hw_sock_raw_mmaped *phw_sock_raw_mmape
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 - 1));
ioctl(phw_sock_raw_mmaped->sockfd, SIOCGIFMTU, &ifr);
phw_sock_raw_mmaped->common.mtu_size = ifr.ifr_mtu;
ec_log(10, "hw_open", "got mtu size %d\n", phw_sock_raw_mmaped->common.mtu_size);
Expand Down

0 comments on commit 60fc7e7

Please sign in to comment.