aboutsummaryrefslogtreecommitdiffstats
path: root/pcap-nit.c
diff options
context:
space:
mode:
authoritojun <itojun>2000-04-27 09:11:11 +0000
committeritojun <itojun>2000-04-27 09:11:11 +0000
commit20d9e08cde232247531358fd448ad845c89c7a16 (patch)
treeae51489e2f967ec34cc9cba84fc74e78b44a1104 /pcap-nit.c
parent14b709dd48cc512bd2c8f0b8ddb57c2ac1fbfc9e (diff)
do not use sprintf(). always use snprintf().
from NetBSD/OpenBSD src/lib/libpcap. use freeifaddrs() if exists.
Diffstat (limited to 'pcap-nit.c')
-rw-r--r--pcap-nit.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/pcap-nit.c b/pcap-nit.c
index a2e2a43..cb4a573 100644
--- a/pcap-nit.c
+++ b/pcap-nit.c
@@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.31 1999-10-07 23:46:40 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.32 2000-04-27 09:11:13 itojun Exp $ (LBL)";
#endif
#include <sys/types.h>
@@ -91,7 +91,7 @@ pcap_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
if (cc < 0) {
if (errno == EWOULDBLOCK)
return (0);
- sprintf(p->errbuf, "pcap_read: %s",
+ snprintf(p->errbuf, sizeof(p->errbuf), "pcap_read: %s",
pcap_strerror(errno));
return (-1);
}
@@ -125,7 +125,8 @@ pcap_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
continue;
default:
- sprintf(p->errbuf, "bad nit state %d", nh->nh_state);
+ snprintf(p->errbuf, sizeof(p->errbuf),
+ "bad nit state %d", nh->nh_state);
return (-1);
}
++p->md.stat.ps_recv;
@@ -174,7 +175,8 @@ nit_setflags(int fd, int promisc, int to_ms, char *ebuf)
nioc.nioc_flags |= NF_PROMISC;
if (ioctl(fd, SIOCSNIT, &nioc) < 0) {
- sprintf(ebuf, "SIOCSNIT: %s", pcap_strerror(errno));
+ snprintf(ebuf, PCAP_ERRBUFF_SIZE, "SIOCSNIT: %s",
+ pcap_strerror(errno));
return (-1);
}
return (0);
@@ -202,15 +204,16 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
bzero(p, sizeof(*p));
p->fd = fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW);
if (fd < 0) {
- sprintf(ebuf, "socket: %s", pcap_strerror(errno));
+ snprintf(ebuf, PCAP_ERRBUFF_SIZE,
+ "socket: %s", pcap_strerror(errno));
goto bad;
}
snit.snit_family = AF_NIT;
(void)strncpy(snit.snit_ifname, device, NITIFSIZ);
if (bind(fd, (struct sockaddr *)&snit, sizeof(snit))) {
- sprintf(ebuf, "bind: %s: %s", snit.snit_ifname,
- pcap_strerror(errno));
+ snprintf(ebuf, PCAP_ERRBUFF_SIZE,
+ "bind: %s: %s", snit.snit_ifname, pcap_strerror(errno));
goto bad;
}
p->snapshot = snaplen;