From: Denis Ovsienko Date: Tue, 3 Dec 2024 20:27:37 +0000 (+0000) Subject: Convert strncpy() in pcap-netmap.c. X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/4e0699f7252ee03461d34752a39892891ce4e8db Convert strncpy() in pcap-netmap.c. Make it clear that the string copying in pcap_netmap_ioctl() is safe. --- diff --git a/pcap-netmap.c b/pcap-netmap.c index 6f334f83..fa7d4289 100644 --- a/pcap-netmap.c +++ b/pcap-netmap.c @@ -139,7 +139,11 @@ pcap_netmap_ioctl(pcap_t *p, u_long what, uint32_t *if_flags) } #endif /* __linux__ */ bzero(&ifr, sizeof(ifr)); - strncpy(ifr.ifr_name, d->req.nr_name, sizeof(ifr.ifr_name)); + /* + * ifreq.ifr_name and nmreq.nr_name have the same size and both + * contain a NUL-terminated string. + */ + (void)pcapint_strlcpy(ifr.ifr_name, d->req.nr_name, sizeof(ifr.ifr_name)); switch (what) { case SIOCSIFFLAGS: /*