X-Git-Url: https://git.tcpdump.org/libpcap/blobdiff_plain/1131a7c26c6f4d4772e4a2beeaf7212f4dea74ac..09b51d326c38ea8e10ce4da09c09d50e08c5aeb8:/pcap-pf.c?ds=sidebyside diff --git a/pcap-pf.c b/pcap-pf.c index c712460f..bd27933e 100644 --- a/pcap-pf.c +++ b/pcap-pf.c @@ -48,7 +48,6 @@ struct rtentry; #include #include -#include #include #include #include @@ -134,6 +133,9 @@ pcap_read_pf(pcap_t *pc, int cnt, pcap_handler callback, u_char *user) bp = pc->bp; /* * Loop through each packet. + * + * This assumes that a single buffer of packets will have + * <= INT_MAX packets, so the packet count doesn't overflow. */ n = 0; pad = pc->fddipad; @@ -158,7 +160,7 @@ pcap_read_pf(pcap_t *pc, int cnt, pcap_handler callback, u_char *user) } } if (cc < sizeof(*sp)) { - pcap_snprintf(pc->errbuf, sizeof(pc->errbuf), + snprintf(pc->errbuf, sizeof(pc->errbuf), "pf short read (%d)", cc); return (-1); } @@ -168,7 +170,7 @@ pcap_read_pf(pcap_t *pc, int cnt, pcap_handler callback, u_char *user) } else sp = (struct enstamp *)bp; if (sp->ens_stamplen != sizeof(*sp)) { - pcap_snprintf(pc->errbuf, sizeof(pc->errbuf), + snprintf(pc->errbuf, sizeof(pc->errbuf), "pf short stamplen (%d)", sp->ens_stamplen); return (-1); @@ -222,7 +224,7 @@ pcap_read_pf(pcap_t *pc, int cnt, pcap_handler callback, u_char *user) } static int -pcap_inject_pf(pcap_t *p, const void *buf, size_t size) +pcap_inject_pf(pcap_t *p, const void *buf, int size) { int ret; @@ -257,7 +259,7 @@ pcap_stats_pf(pcap_t *p, struct pcap_stat *ps) * full. * * "ps_ifdrop" counts packets dropped by the network - * inteface (regardless of whether they would have passed + * interface (regardless of whether they would have passed * the input filter, of course). * * If packet filtering is not being done in the kernel: @@ -269,7 +271,7 @@ pcap_stats_pf(pcap_t *p, struct pcap_stat *ps) * the userland filter. * * "ps_ifdrop" counts packets dropped by the network - * inteface (regardless of whether they would have passed + * interface (regardless of whether they would have passed * the input filter, of course). * * These statistics don't include packets not yet read from @@ -327,7 +329,7 @@ pcap_activate_pf(pcap_t *p) p->fd = pfopen(p->opt.device, O_RDONLY); if (p->fd < 0) { if (errno == EACCES) { - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "pf open: %s: Permission denied\n" "your system may not be properly configured; see the packetfilter(4) man page", p->opt.device); @@ -460,7 +462,7 @@ pcap_activate_pf(pcap_t *p) * framing", there's not much we can do, as that * doesn't specify a particular type of header. */ - pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "unknown data-link type %u", devparams.end_dev_type); err = PCAP_ERROR; goto bad; @@ -536,7 +538,7 @@ pcap_create_interface(const char *device _U_, char *ebuf) { pcap_t *p; - p = pcap_create_common(ebuf, sizeof (struct pcap_pf)); + p = PCAP_CREATE_COMMON(ebuf, struct pcap_pf); if (p == NULL) return (NULL);