X-Git-Url: https://git.tcpdump.org/libpcap/blobdiff_plain/b1f597f914be77473ed685e0f0361a7f1d31cb0f..2c7f925c86ec27823da37c8e21c3eaee9294976c:/pcap-netmap.c diff --git a/pcap-netmap.c b/pcap-netmap.c index 573f4c31..56a6bc41 100644 --- a/pcap-netmap.c +++ b/pcap-netmap.c @@ -24,9 +24,7 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H #include -#endif #include #include @@ -35,6 +33,7 @@ #include #include #include +#include #define NETMAP_WITH_LIBS #include @@ -133,15 +132,19 @@ pcap_netmap_ioctl(pcap_t *p, u_long what, uint32_t *if_flags) struct ifreq ifr; int error, fd = d->fd; -#ifdef linux +#ifdef __linux__ fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd < 0) { fprintf(stderr, "Error: cannot get device control socket.\n"); return -1; } -#endif /* linux */ +#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: /* @@ -194,9 +197,9 @@ pcap_netmap_ioctl(pcap_t *p, u_long what, uint32_t *if_flags) #endif /* __FreeBSD__ */ } } -#ifdef linux +#ifdef __linux__ close(fd); -#endif /* linux */ +#endif /* __linux__ */ return error ? -1 : 0; } @@ -237,7 +240,7 @@ pcap_netmap_activate(pcap_t *p) } #if 0 fprintf(stderr, "%s device %s priv %p fd %d ports %d..%d\n", - __FUNCTION__, p->opt.device, d, d->fd, + __func__, p->opt.device, d, d->fd, d->first_rx_ring, d->last_rx_ring); #endif pn->d = d;