]> The Tcpdump Group git mirrors - libpcap/commitdiff
Convert strncpy() in pcap-netmap.c.
authorDenis Ovsienko <[email protected]>
Tue, 3 Dec 2024 20:27:37 +0000 (20:27 +0000)
committerDenis Ovsienko <[email protected]>
Tue, 3 Dec 2024 21:36:55 +0000 (21:36 +0000)
Make it clear that the string copying in pcap_netmap_ioctl() is safe.

pcap-netmap.c

index 6f334f8307b789fe4632b51dc3034680192812d6..fa7d4289a655d2cc68057e37b17675e6da635477 100644 (file)
@@ -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:
                /*